JavaScript Date Reference

Every Date method — including the classic getMonth 0-indexed gotcha, timezone-offset sign trap, and the modern Intl.DateTimeFormat.

Constructor & Static

Getters

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.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.getDate
Returns the day of the month (1-31) in LOCAL time. Do not confuse this with getDay, which returns the weekday.
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.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.
Date.prototype.getTime
Returns the underlying timestamp of the date as milliseconds since the Unix epoch (1970-01-01T00:00:00Z). This is the canonical way to compare, subtract, or serialize a Date as a number.
Date.prototype.getTimezoneOffset
Returns the difference between UTC and the host's local time in MINUTES with the SIGN REVERSED from the conventional offset. So India (UTC+05:30) returns -330 and New York in EST (UTC-05:00) returns 300.

Setters

Formatting

Date.prototype.toISOString
Returns the date as an ISO 8601 extended-format string in UTC, always ending in 'Z'. This is the canonical machine-readable serialization and the format most APIs and databases accept.
Date.prototype.toJSON
Returns an ISO 8601 UTC string suitable for JSON serialization; called automatically by JSON.stringify when it encounters a Date. Equivalent to toISOString() for valid dates, but returns null for Invalid Dates instead of throwing.
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.toLocaleTimeString
Returns the time portion formatted for a given locale and options, without the date. Same locale/options rules as toLocaleDateString.
Date.prototype.toLocaleString
Returns date and time together formatted for a given locale. Accepts the union of date and time options from Intl.DateTimeFormat.
Date.prototype.toDateString
Returns the date portion of the Date as a fixed English string, e.g. 'Sun Jul 19 2026'. Companion to toTimeString which returns something like '15:30:00 GMT+0530 (India Standard Time)'.
Date.prototype.toUTCString
Returns the date as a string in the older RFC 7231 / IMF-fixdate format, e.g. 'Sun, 19 Jul 2026 00:00:00 GMT'. This is the exact format required by HTTP headers like Date, Expires, and cookies.
Date.prototype.toString
Returns a fixed English representation of the date in LOCAL time, e.g. 'Sun Jul 19 2026 05:30:00 GMT+0530 (India Standard Time)'. Called implicitly by template literals and string concatenation.

Parsing

UTC Variants

Intl (Internationalization)

Related references