Date.parse()
Exactly one input format is specified: ISO 8601. Everything else is implementation-defined, which means it works in your browser and may not in someone else.
Demo
ISO input gives a clean timestamp, and that is the only form the specification guarantees. The written-date case works in every major engine but is not required to. The fourth case is the one that causes real damage: '15/03/2026' is unambiguous to a European reader and simply invalid here — engines try month/day/year first, and 15 is not a month, so you get NaN. Had the day been 12 or less it would have parsed as a DIFFERENT date rather than failing, which is far worse.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| string | string | yes | A date string. ISO 8601 is specified and reliable. Other formats are accepted at each engine discretion, so results vary between browsers and Node versions. |
Return value
number — Milliseconds since the epoch, or NaN if the string could not be parsed. Never throws — a bad input is silently NaN.
Common patterns
const t = Date.parse(s); if (Number.isNaN(t)) reject('bad date');
const [d, m, y] = s.split('/').map(Number); const t = Date.UTC(y, m - 1, d);
const d = new Date(isoString);
Examples
Pitfalls
Date.parse('Mar 15 2026 12:00')
Date.parse('2026-03-15T12:00:00Z')
const d = new Date('03/04/2026'); [d.getMonth(), d.getDate()]
const [day, mon, yr] = '04/03/2026'.split('/').map(Number); const d = new Date(yr, mon - 1, day); [d.getMonth(), d.getDate()]
Date.parse('nonsense') + 86400000
const t = Date.parse(s); if (Number.isNaN(t)) throw new Error('bad date');
Date.parse('2026-03-15T00:00') === Date.parse('2026-03-15')
Date.parse('2026-03-15T00:00Z') === Date.parse('2026-03-15')
When to use
- Parsing ISO 8601 strings from an API or a database
- Validating that a string is a usable date, via the NaN check
- Comparing two dates as numbers without building Date objects
- Non-ISO formats → parse the parts yourself, or use a library
- User-typed dates → a date input, or an explicit format
- You want a Date object → new Date(string), which calls this anyway
- Ambiguous day/month order → never rely on the engine guess
Notes
FAQ
ISO 8601 only — a date, optionally with a time and an offset. Everything else, including the RFC 2822 style that most engines accept, is implementation-defined. If you control the producer, emit toISOString output.
Date.parse('2026-03-15'); Date.parse('2026-03-15T12:00:00Z'); Date.parse('2026-03-15T12:00:00+02:00');