JavaScript parse()Method

JavaScript Date Object

Examples

Returns the number of milliseconds between 1970/01/01 and 2012/3/21:

var d = Date.parse("March 21, 2012");

dOutput:


Try it Yourself »

Definition and Usage

The parse() method parses a date-time string and returns the number of milliseconds between midnight of 1970/1/1 and that date-time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the parse() method.


Syntax

Date.parse(datestring)

Parameter Values

Parameter Description
datestring Required. A string representing the date and time.
Type Description
Number The number of milliseconds between the specified date and time and midnight of 1970/1/1 (GMT time).

Technical Details

JavaScript Version: 1.0


More Examples

Examples

In this example, we will get the number of milliseconds from 1970/01/01 to 2012/03/21:

var d=Date.parse("March 21, 2012"); var minutes=1000*60; var hours=minutes*60; var days=hours*24; var years=days*365; var y=Math.floor(d/years);

yOutput:


Try it Yourself »


JavaScript Date Object

Other Extensions