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.

Date static methodES1 (1997)Live demo
Common call
Date.parse('2026-03-15T12:00:00Z')
Returns
a timestamp, or NaN
Replaces
nothing — the Date constructor uses it internally
Watch out
only ISO is portable; NaN is the failure signal
Date.parse(stringstring — 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.type: string · required)
→ number

Demo

Live evaluation
Try:
Inputs
sstringa date string to parse
Output
Date.parse('2026-03-15T12:00:00Z')
1773576000000

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

NameTypeRequiredDescription
stringstringyesA 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

Parse ISO and validate
NaN is the only failure signal.
const t = Date.parse(s);
if (Number.isNaN(t)) reject('bad date');
Parse a known non-ISO format yourself
Explicit beats guessing.
const [d, m, y] = s.split('/').map(Number);
const t = Date.UTC(y, m - 1, d);
The constructor does the same thing
new Date(string) calls this internally.
const d = new Date(isoString);

Examples

1. ISO with a zone
Date.parse('2026-03-15T12:00:00Z')
Returns
1773576000000
2. Date only is UTC
Date.parse('2026-03-15')
Returns
1773532800000
3. Unparseable
Date.parse('nonsense')
Returns
NaN
4. European order fails
Date.parse('15/03/2026')
Returns
NaN
5. Never throws
typeof Date.parse('nonsense')
Returns
'number'
6. The constructor agrees
new Date('nonsense').toString()
Returns
'Invalid Date'

Pitfalls

1. Only ISO 8601 is specified
Every other format is implementation-defined. A string that parses in Chrome may give NaN in Safari or a different instant in Node — and because failures are NaN rather than exceptions, the problem surfaces as a nonsensical date deep in your data.
Engine-dependent
Date.parse('Mar 15 2026 12:00')
works today, not guaranteed
Use ISO
Date.parse('2026-03-15T12:00:00Z')
1773576000000
2. Ambiguous day/month order parses to the wrong date
Engines try month/day/year for slash-separated input, so 03/04/2026 is 4 March, not 3 April. When the day exceeds 12 you get NaN and notice; when it does not, you get a silently wrong date six months out. This is the worst failure mode in the whole Date API.
Read as month/day
const d = new Date('03/04/2026');
[d.getMonth(), d.getDate()]
[2, 4] // 4 March
Parse explicitly
const [day, mon, yr] = '04/03/2026'.split('/').map(Number);
const d = new Date(yr, mon - 1, day);
[d.getMonth(), d.getDate()]
[2, 4] // 4 March, as intended
3. It returns NaN rather than throwing
NaN then propagates through arithmetic and comparisons without error, so a bad date can be stored, compared and rendered before anyone notices. Every parse of untrusted input needs an explicit check.
Spreads quietly
Date.parse('nonsense') + 86400000
NaN
Check it
const t = Date.parse(s);
if (Number.isNaN(t)) throw new Error('bad date');
fails early
4. A date-time string without an offset is local
Shared with the constructor and worth repeating: a bare date is UTC, a date with a time but no zone is local. The same calendar day can therefore parse to two different instants depending on which form you used.
Local
Date.parse('2026-03-15T00:00') === Date.parse('2026-03-15')
false, outside UTC
Add the Z
Date.parse('2026-03-15T00:00Z') === Date.parse('2026-03-15')
true

When to use

Use it
  • 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
Reach for something else
  • 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

Complexity
O(n) in the length of the string
Return
A number, or NaN; nothing is allocated
CPython impl
V8: Builtins-date-parse / dateparser.cc
Memory
No allocation
Thread-safe
Single-threaded

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');

History

ES1
Date.parse present from the first version, with entirely implementation-defined behaviour.
ES5
ISO 8601 parsing specified, giving one format that is guaranteed.
ES2016
Clarified that date-only strings are UTC and date-time strings without an offset are local.