formatting
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.toDateString() Parameters
| Parameter | Purpose |
|---|---|
| () | no arguments; English-only, locale-independent |
| toTimeString() | time counterpart with timezone label |
Examples
console.log(new Date('2026-07-19T00:00:00Z').toDateString()); // 'Sun Jul 19 2026' (in UTC zone) no time portion
console.log(new Date('2026-07-19T15:30:00Z').toTimeString()); // '15:30:00 GMT+0000 (Coordinated Universal Time)' style time + zone
console.log(new Date().toString() === new Date().toDateString() + ' ' + new Date().toTimeString()); // conceptually true toString ~= date + time
Gotcha
Always English (not localized) and uses local time. For anything user-facing prefer toLocaleDateString or Intl.DateTimeFormat.
Related
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.
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.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.toLocaleTimeString
Returns the time portion formatted for a given locale and options, without the date. Same locale/options rules as toLocaleDateString.