The Date methods "fix" weird non-real dates. If you set the date (day-of-month) to zero, you get the last day of the previous month. All of the setter methods behave similarly.

Note also that months are numbered from zero: January is 0, not 1.

Answer from Pointy on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_getdate.asp
JavaScript Date getDate() Method
The getDate() method returns the day of the month (1 to 31) of a date. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Date.prototype.getDate() Returns the day of the month (1 – 31) for the specified date according to local time. Date.prototype.getDay() Returns the day of the week (0 – 6) for the specified date according to local time. Date.prototype.getFullYear() Returns the year (4 digits for 4-digit ...
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Date Methods
The getDate() method returns the day of a date as a number (1-31):
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
How to use getDate() and setDate() - JavaScript - The freeCodeCamp Forum
December 21, 2020 - Hi guys, I’m stuck with this exercice: // write a function called tellAge that tells you how old you are based on the date of birth passed. // this function will take 3 arguments month, day and year // You should use the Date object to set the value of today.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-date-getdate-method
JavaScript Date getDate() Method - GeeksforGeeks
July 11, 2025 - The JavaScript getDate() method returns the day of the month (from 1 to 31) for a specified date according to local time.
🌐
Reddit
reddit.com › r/javascript › can you explain date.prototype.getdate() vs. date.now() in other words built-in object method differences
r/javascript on Reddit: Can you explain Date.prototype.getDate() vs. Date.now() in other words built-in object method differences
March 1, 2018 -

Redditors, Can someone please explain why (what is the reasoning/advantage)

below have direct methods

Date.UTC()
Date.now()
Date.parse()

And below have prototype methods

Date.prototype.getDate()
Date.prototype.getDay()

For testing:

const functionName = fn => (console.log(fn.name), fn);

functionName(Date.prototype.getDate); // logs getDate
functionName(Date.getDate); // logs Cannot read property     'name' of undefined
functionName(Date.now); // logs now
🌐
HCL Software
help.hcl-software.com › dom_designer › 9.0.1 › reference › r_wpdr_standard_date_getdate_r.html
getDate (JavaScript)
Date (Standard - JavaScript) getDate() : int · This computed label adds one year to the current date. One day is first subtracted if the date is February 29 (leap year) so it appears as February 28 instead of March 1 in the next year.
🌐
TutorialsPoint
tutorialspoint.com › javascript › date_getdate.htm
JavaScript Date getDate() Method
In JavaScript, the Date.getDate() method is used to retrieve the "day of month" from a date object. This method does not accept any parameters instead; it returns the day of the month as a numeric value between 1 and 31, representing the current ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript | MDN
The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
The Date() constructor creates Date objects. When called as a function, it returns a string representing the current time.
🌐
Codecademy
codecademy.com › docs › javascript › dates › .getdate()
JavaScript | Dates | .getDate() | Codecademy
May 24, 2023 - The .getDate() method returns the day of the month. ... Front-end engineers work closely with designers to make websites beautiful, functional, and fast. ... Learn how to use JavaScript — a powerful and flexible programming language for adding ...
🌐
Educative
educative.io › answers › what-is-getdate-in-javascript
What is getDate() in JavaScript?
Without parameters, getDate() is used to get the day of the current date.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › setDate
Date.prototype.setDate() - JavaScript | MDN
July 30, 2025 - const event = new Date("August 19, 1975 23:15:30"); event.setDate(24); console.log(event.getDate()); // Expected output: 24 event.setDate(32); // Only 31 days in August! console.log(event.getDate()); // Expected output: 1 · js · setDate(dateValue) dateValue ·
🌐
freeCodeCamp
freecodecamp.org › news › javascript-get-current-date-todays-date-in-js
JavaScript Get Current Date – Today's Date in JS
November 7, 2024 - The date object supports numerous ... since it’s a zero based index (meaning it starts from 0). getDate() – gets the day as a number (1-31)....
Top answer
1 of 3
6

See the documentation

Specifically - "If a time zone is not specified and the string is in an ISO format recognized by ES5, UTC is assumed. GMT and UTC are considered equivalent. The local time zone is used to interpret arguments in RFC2822 Section 3.3 format (or any format not recognized as ISO 8601 in ES5) that do not contain time zone information"

and

"Given a date string of "March 7, 2014", parse() assumes a local time zone, but given an ISO format such as "2014-03-07" it will assume a time zone of UTC. Therefore Date objects produced using those strings will represent different moments in time unless the system is set with a local time zone of UTC"

The last 2 of your examples are "ISO format recognized by ES5"

2 of 3
6

Date("January 1, 2015") is interpreted as local date.
Date("2015-01-01") is interpreted as a UTC date in ES5, local date in ES6.
getDate() gets the local date.
getUTCdate() gets the UTC date.

When you mix and match local and UTC, then you get surprising results.

Thanks, @preston-s. Your comments took me a long way towards answering my question. But, it's interesting that the interpretation of Date("2015-01-01") will change from UTC in ES5 to local time in ES6. Does anyone know when the different browsers are expected to switch over to the new behavior? I would expect some things to break at that point in time.

ES5: 'The value of an absent time zone offset is “Z”.'

ES6: 'If the time zone offset is absent, the date-time is interpreted as a local time.'

Given all this information, here are two solutions which will work across ES5 and ES6. Several other solutions are possible.
1) Use local date in and out.

var d;
d = new Date("January 1, 2015");
alert('Month: ' + d.getMonth() + ' Date: ' + d.getDate() + ' UTC: ' + d.toUTCString());
// Month: 0 Date: 1 UTC: Thu, 01 Jan 2015 05:00:00 GMT

2) Use UTC date in and out. Spell out the time zone so this will still work in ES6.

var d;
d = new Date("2015-01-01T00:00:00.000Z");
alert('UTC Month: ' + d.getUTCMonth() + ' UTC Date: ' + d.getUTCDate() + ' UTC: ' + d.toUTCString());
// UTC Month: 0 UTC Date: 1 UTC: Thu, 01 Jan 2015 00:00:00 GMT
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getDay
Date.prototype.getDay() - JavaScript | MDN
The getDay() method of Date instances returns the day of the week for this date according to local time, where 0 represents Sunday. For the day of the month, see Date.prototype.getDate(). const birthday = new Date("August 19, 1975 23:15:30"); const day1 = birthday.getDay(); // Sunday - Saturday ...
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › jsref › jsref_getdate.asp.html
JavaScript getDate() Method
The getDate() method returns the day of the month (from 1 to 31) for the specified date. ... Color Converter Google Maps Animated Buttons Modal Boxes Modal Images Tooltips Loaders JS Animations Progress Bars Dropdowns Slideshow Side Navigation HTML Includes Color Palettes Code Coloring ...