getters
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.getDay() Parameters
| Parameter | Purpose |
|---|---|
| () | no arguments; returns 0-6 |
| 0 | Sunday (not Monday) |
| 6 | Saturday |
Examples
console.log(new Date('2026-07-19T00:00:00Z').getUTCDay()); // 0 (Sunday) Sunday = 0
const days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; console.log(days[new Date().getDay()]); weekday name
const isWeekend = d => d.getDay() % 6 === 0; console.log(isWeekend(new Date('2026-07-19'))); // true 0 or 6 = weekend
Gotcha
Returns 0-6 with Sunday=0 (US convention), not Monday=0 (ISO). For ISO weekday (Mon=1..Sun=7) use ((d.getDay() + 6) % 7) + 1.
Related
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.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.toLocaleDateString
Returns the date portion formatted for a given locale and options, without the time. For repeated formatting, cache an Intl.DateTimeFormat instead - it is significantly faster.
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.