JavaScript Date.parse() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.parse() is a static method that parses a date string and returns that instant as milliseconds since January 1, 1970 UTC. Invalid input returns NaN (it does not throw).

Remember
Date.parse(dateString)

→ number (epoch ms) on success
→ NaN if the string cannot be parsed

Date.parse("1970-01-01T00:00:00Z")  → 0
Date.parse("not-a-date")            → NaN

Date.parse(str)  ≈  new Date(str).getTime()

Syntax

Call Date.parse. Start with this line.

JavaScript
Date.parse(dateString)
CallWhat it does
Date.parse(dateString)Primary signature.
Date.parse(...)Call with the arguments your case needs.

Built into JavaScript. Call Date.parse(...) on the Date constructor — no import required.

Library declarations
JavaScript
Date.parse(dateString)

Parameters

ParameterDescription
dateStringRequired. String to parse (ISO recommended)

Return Value

Return ValueDescription
*Epoch ms, or NaN

JavaScript Examples

Example 1 — MDN Epoch and Release Dates

Parse the classic Unix epoch and MDN’s JavaScript-release style string.

JavaScript
const unixTimeZero = Date.parse("1970-01-01T00:00:00Z");
const javaScriptRelease = Date.parse("04 Dec 1995 00:12:00 GMT");

console.log(unixTimeZero);      // 0
console.log(javaScriptRelease); // 818035920000
Try It Yourself

How It Works

  1. Static call. Use Date.parse(...) — no instance needed.
  2. ISO with Z. Explicit UTC maps the epoch string to 0.
  3. GMT string. The MDN-style release string parses to a fixed timestamp.
  4. Return type. Both results are numbers (epoch milliseconds).

Example 2 — ISO Date-Only String

Date-only ISO forms are treated as UTC midnight.

JavaScript
const a = Date.parse("2019-01-01");
const b = Date.parse("2019-01-01T00:00:00.000Z");

console.log(a);       // 1546300800000
console.log(b);       // 1546300800000
console.log(a === b); // true
Try It Yourself

How It Works

  1. Date-only. 2019-01-01 means UTC midnight (MDN).
  2. Explicit UTC. Adding T00:00:00.000Z is the same instant.
  3. Equal numbers. Both parses return 1546300800000.
  4. Contrast. 2019-01-01T00:00:00 (no zone) would be local time.

Example 3 — Date.parse() vs new Date()

Parse returns a number; the constructor returns a Date. Invalid input → NaN.

JavaScript
const s = "2026-03-15T12:00:00.000Z";

console.log(Date.parse(s) === new Date(s).getTime()); // true
console.log(Number.isNaN(Date.parse("not-a-date")));  // true
console.log(typeof Date.parse(s));                    // "number"
Try It Yourself

How It Works

  1. Same instant. Date.parse(s) matches new Date(s).getTime().
  2. Choose the type. Use parse for a number; use new Date for an object.
  3. Failed parse. Bad strings yield NaN — check with Number.isNaN.
  4. No throw. Always validate; do not wrap in try/catch for parse failures.

Browser & Runtime Support

Date.parse() is part of the language from early ECMAScript and is Baseline Widely available (MDN). ISO 8601 support is required; other formats are not.

✓ Baseline · Widely available

Date.parse()

Supported in every modern browser and Node.js. Rely on ISO strings for consistent results.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Date.parse() Excellent

Bottom line: The API is everywhere — portable parsing depends on using ISO 8601, not on feature detection.

Frequently Asked Questions

A number: milliseconds since January 1, 1970 UTC for the parsed string, or NaN if parsing fails. It does not throw.
Date.parse() returns epoch milliseconds. new Date(string) returns a Date object. For valid strings, Date.parse(str) equals new Date(str).getTime().
Prefer ISO 8601 such as 2026-03-15T12:00:00.000Z. Non-standard formats are implementation-defined and may differ across browsers (MDN).
Use Number.isNaN(Date.parse(input)). Failed parses return NaN—not an exception.
ISO date-only forms like 2019-01-01 are treated as UTC midnight. A date-time without a timezone (2019-01-01T00:00:00) is local time (MDN).
No. Date.now() returns the current timestamp. Date.parse() converts a date string into a timestamp.

Next: setDate()

Learn how to set the day of the month on a Date object.

setDate() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful