Skip to content
Tutorials Center
My learning

Topics

JavaScript Reference ยท Date and Intl

Date.parse() and Date.UTC()

Reference for JavaScript Date.parse() and Date.UTC(): turn strings or UTC date parts into millisecond timestamps, and avoid parsing and time zone traps.

Date.parse() and Date.UTC() are static methods that return a timestamp (milliseconds since the Unix epoch) instead of a Date object. Date.parse() reads a date string. Date.UTC() builds a timestamp from year, month, day and time parts that you give in UTC, not in local time.

Date.UTC() is the reliable way to create a moment independent of the user's time zone. Date.parse() is dependable only for ISO 8601 strings.

JavaScript
Date.parse("2026-03-15T09:30:00Z"); // 1773567000000
Date.UTC(2026, 2, 15, 9, 30);       // 1773567000000

Try it

JS Parse ISO strings

Press Run (or Ctrl + Enter) to see the console output here.

No output.

JS Build timestamps with Date.UTC()

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Syntax

JavaScript
Date.parse(dateString)
Date.UTC(year)
Date.UTC(year, monthIndex, day, hours, minutes, seconds, milliseconds)
Name Description
dateString The string to parse. ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ and its shorter forms) is guaranteed.
year The full year. A value from 0 to 99 is treated as 1900 to 1999.
monthIndex Month starting at 0. Defaults to 0.
day Day of the month, starting at 1. Defaults to 1.
hours, minutes, seconds, milliseconds Time parts in UTC. Each defaults to 0.

Return value: a number of milliseconds since the epoch, or NaN if the input cannot be understood.

Exceptions: none. Bad input gives NaN.

Usage notes

  • ISO only, if you want portability. Strings like "03/15/2026" or "March 15, 2026 9:30" are parsed by engine-specific rules and may give different results (or NaN) elsewhere.
  • Date-only vs date-time. "2026-03-15" means UTC midnight. "2026-03-15T00:00" (no zone) means local midnight. Add Z or an offset such as +02:00 to be explicit.
  • Offsets are applied. "...T09:30:00+02:00" is two hours earlier in UTC than the same time with Z.
  • Impossible dates return NaN in ISO strings (month 13, day 45). Date.UTC() instead rolls over, so Date.UTC(2026, 1, 30) lands in March.
  • Date.UTC() ignores the local zone, which makes it perfect for tests, calendars and arithmetic on whole days.
  • Returns a number, not a Date. Pass it to new Date() when you need the object.
  • Two-digit years (0 to 99) are mapped to the 1900s in Date.UTC(); if you really need year 50, use setUTCFullYear() on a date.
  • Date.parse(x) and new Date(x).getTime() use the same parsing rules and give the same number.

Browser support

Both methods work in every browser and runtime. Parsing of non-ISO formats is not consistent between engines.