JavaScript Dates: A Practical Guide
JavaScript's Date represents an instant as milliseconds from the Unix epoch. Formatting and parsing choices determine how that instant appears to people.
What a Date value represents
A JavaScript Date stores a numeric time value measured in milliseconds relative to 1 January 1970 at 00:00 UTC. A single value can be displayed as UTC or as local time without changing the instant it represents. A browser normally uses the device's configured time zone when producing local output.
For example, new Date(0).toISOString() returns 1970-01-01T00:00:00.000Z. The same instant may be displayed as an earlier local calendar date west of UTC. That is a formatting difference, not evidence that the underlying time value has changed. See the Unix epoch guide for the shared starting point.
Milliseconds, seconds and precision
Date.now() returns milliseconds. Many APIs describe Unix timestamps in seconds, so interpreting one unit as the other changes the result dramatically. A value in seconds can be converted to milliseconds by multiplying by 1,000, provided it is within the supported Date range. When sending data to another system, document the unit instead of guessing from the number of digits.
A Date has millisecond resolution, but that does not prove the device clock is accurate to a millisecond. The platform may reduce timer precision or have an unsynchronized clock. For elapsed performance measurement inside a page, a monotonic timer such as performance.now() is usually more appropriate than subtracting two wall-clock readings.
Parsing date-only and date-time strings
The built-in date-time string format has an important distinction: a date-only string such as 2026-05-04 is interpreted as UTC, while a date-time without an offset such as 2026-05-04T09:30:00 is interpreted as local time. If a date-only value is displayed in a negative offset, the resulting local date can be the previous day.
A birthday or holiday is often a calendar date, not an instant at midnight UTC. Keep its year, month and day as a date-only value when no time zone is intended. For an exact event, include Z or an explicit numeric offset in the exchanged string. Avoid relying on implementation-dependent parsing of informal date strings.
Formatting and named time zones
toISOString() returns a UTC string ending in Z. Methods such as toLocaleString() can format a value for a language and region. To display the same instant in a particular location, use Intl.DateTimeFormat with a supported IANA identifier such as Europe/London, rather than adding a hard-coded offset.
For future local schedules, retain the intended local time and named zone alongside any resolved instant. Clock changes can make a local time missing or repeated, and future rules can change. Read our time-zone guide and consult the MDN Date reference for the precise behavior of the methods you use.
A practical checklist
Validate the input before formatting it: an invalid Date cannot produce a useful ISO string. Identify whether the input is a date, an instant or a recurring local schedule. Record the timestamp unit, choose UTC for interchange when appropriate, and specify the desired display zone. Test dates near midnight and daylight-saving transitions.
Try the timestamp converter to inspect an instant in UTC and local time. For a comparison of timestamp units and accuracy, continue to timestamp precision.