JavaScript parse() method
Example
Returns the milliseconds between 1970/01/01 and 2012/3/21:
var d = Date.parse("March 21, 2012");
d Output result:
Try it »
Definition and Usage
The parse() method parses a date/time string and returns the number of milliseconds since midnight 1970/1/1 to the specified date/time.
Browser support





All major browsers support the parse() method.
Syntax
Date
.parse(
datestring
)
Parameter value
| Parameters | Description |
|---|---|
| datestring | Required. A string representing the date and time. |
| Type | Description |
|---|---|
| Number | The number of milliseconds between the specified date/time and midnight 1970/1/1 (GMT). |
Technical Details
| JavaScript version: | 1.0 |
|---|
More examples
Example
In this example, we will get the 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);
y Output result:
Try it »
JavaScript Date object