Name

Date.parse() — parse a date/time string

Synopsis

Date.parse(date)

Arguments

date

A string containing the date and time to be parsed.

Returns

The number of milliseconds between the specified date and time and midnight GMT on January 1, 1970.

Description

Date.parse()is a static method of Date. It parses the date specified by its single string argument returns it as the number of milliseconds since the epoch. This return value can be used directly, used to create a new Date object, or used to set the date in an existing Date object with Date.setTime().

ECMAScript 5 requires this method to be able to parse strings returned by the Date.toISOString() method. In ECMAScript 5 and before, this method is also required to be able to parse the implementation-dependent strings returned by the toUTCString() and toString() methods.

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.