Date

A Date wraps one number: milliseconds since 1 January 1970 00:00:00 UTC (the Unix epoch), ignoring leap seconds. There is no literal syntax, and Date() without new returns a string. Comparison operators and unary + work on dates because they convert to that number. The API dates from 1995 and carries traps: months count from 0, out-of-range fields roll over silently, and string parsing depends on the format. These examples ran in GMT+8.

Constructing dates and the classic pitfallsJavaScriptLive
console.log(typeof Date(), typeof new Date());           // without new: a string
console.log(new Date(1982, 4, 25, 13).toString());       // month 4 is May
console.log(new Date(1982, 13, 25).toDateString());      // month 13 rolls into 1983
console.log(new Date('2026-09-15').toISOString());       // date-only ISO: UTC midnight
console.log(new Date('2026-09-15T00:00').toISOString()); // date-time: local midnight
console.log(new Date('25-05-1982').getTime(), +new Date(0), new Date(2026, 0) < new Date());

Store and transmit timestamps or full ISO 8601 strings with an offset (2026-09-15T09:30:00Z), and convert to local time only for display. For new code, prefer Temporal (Temporal).

Subsections