getters
Date.prototype.getDate
Returns the day of the month (1-31) in LOCAL time. Do not confuse this with getDay, which returns the weekday.
date.getDate() Parameters
| Parameter | Purpose |
|---|---|
| () | no arguments; returns 1-31 |
| local time | use getUTCDate for the UTC day-of-month |
Examples
console.log(new Date('2026-07-19T00:00:00Z').getUTCDate()); // 19 day of month
console.log(new Date(2026, 1, 0).getDate()); // 31 (last day of Jan) day 0 rolls to previous month
console.log(new Date(2026, 2, 0).getDate()); // 28 (Feb 2026 has 28 days) trick for days-in-month
Gotcha
getDate is 1-31 (day-of-month). It is NOT the same as getDay (0-6 weekday) - the names are famously confusing.
Related
Date.prototype.getDay
Returns the weekday of the date in LOCAL time as an integer from 0 (Sunday) to 6 (Saturday). Named confusingly close to getDate but returns something completely different.
Date.prototype.getMonth
Returns the month of the date in LOCAL time as an integer from 0 (January) to 11 (December). This zero-based indexing is the single most common source of off-by-one date bugs in JavaScript.
Date.prototype.getFullYear
Returns the 4-digit year of the date according to LOCAL time. Prefer this over the deprecated getYear(), which returns year-1900.
Date.prototype.getHours
Returns the hour of the date in LOCAL time as an integer from 0 to 23. Companion methods getMinutes, getSeconds, and getMilliseconds work the same way for their respective units.
Date.prototype.getMinutes
Returns the minutes portion of the date in LOCAL time as an integer from 0 to 59. The identically shaped getSeconds (0-59) and getMilliseconds (0-999) round out the sub-hour getters.