Because getmonth() start from 0. You may want to have d1.getMonth() + 1
to achieve what you want.
More Related Contents:
- How to calculate number of days between two dates?
- Get week of year in JavaScript like in PHP
- How do you display JavaScript datetime in 12 hour AM/PM format?
- Javascript add leading zeroes to date
- JavaScript seconds to time string with format hh:mm:ss
- Get the time difference between two datetimes
- Comparing date part only without comparing time in JavaScript
- Get String in YYYYMMDD format from JS date object?
- new Date() works differently in Chrome and Firefox
- Date constructor returns NaN in IE, but works in Firefox and Chrome
- how to parse a “dd/mm/yyyy” or “dd-mm-yyyy” or “dd-mmm-yyyy” formatted date string using JavaScript or jQuery [duplicate]
- Parsing a string to a date in JavaScript
- new Date() is working in Chrome but not Firefox
- How to parse a time into a Date object from user input in JavaScript?
- “Deprecation warning: moment construction falls back to js Date” when trying to convert RFC2822 date in moment.js
- Add A Year To Today’s Date
- How to JSON stringify a javascript Date and preserve timezone
- Min/Max of dates in an array?
- Checking if two Dates have the same date info
- How to get year/month/day from a date object?
- how to determine if date is weekend in javascript [closed]
- Calculate Timezone offset only for one particular timezone
- How to split a string at the first `/` (slash) and surround part of it in a “?
- Format date and Subtract days using Moment.js
- add/subtract business days in Javascript
- Javascript Invalid Date Error in Internet Explorer
- Add 30 days to date (mm/dd/yy)
- How do I format a Javascript Date?
- Get today date in Google Apps Script
- moment.js isValid function not working properly