parsing

Date.parse

Parses a date string and returns the corresponding milliseconds since the Unix epoch, or NaN if unrecognized. Only the ISO 8601 subset is guaranteed portable; any other format is implementation-defined.

Date.parse(dateString)

Parameters

Parameter Purpose
'YYYY-MM-DD' date-only ISO string; treated as UTC
'YYYY-MM-DDTHH:mm:ssZ' full ISO instant with explicit UTC
'YYYY-MM-DDTHH:mm:ss+HH:mm' ISO with explicit offset

Examples

console.log(Date.parse('2026-07-19T00:00:00Z')); // 1784332800000

ISO instant

console.log(Date.parse('2026-07-19')); // parsed as UTC midnight

date-only is UTC

console.log(Date.parse('July 19, 2026')); // implementation-defined, avoid

non-ISO is unreliable

console.log(Number.isNaN(Date.parse('not a date'))); // true

invalid input yields NaN

Gotcha

Behavior for non-ISO strings varies by engine; always feed ISO 8601. 'YYYY-MM-DD' is interpreted as UTC but 'YYYY-MM-DDTHH:mm:ss' without a zone is LOCAL.

Related

← All JS Date methods · Math methods · Cron syntax