JavaScript Date parse() Method
- Previous Page now()
- Next Page prototype
- Go to the Previous Level JavaScript Date Reference Manual
Definition and Usage
parse()
This method parses a date string and returns the milliseconds between the date string and midnight on January 1, 1970.
Description
This is a static method of the Date object. It is generally called in the form of Date.parse(), rather than through dateobject.parse() to call this method.
Example
Example 1
Returns the milliseconds between January 1, 1970, and March 21, 2012:
var d = Date.parse("March 21, 2012");
Example 2
Calculate the number of years between January 1, 1970, and March 21, 2012:
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.round(d / years);
Syntax
Date.parse(datestring)
Parameter
Parameter | Description |
---|---|
datestring | Required. A string representing the date. |
Technical Details
Return value: | A number representing the milliseconds between the specified date and time and midnight on January 1, 1970 (GMT time). |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
parse() | Support | Support | Support | Support | Support |
- Previous Page now()
- Next Page prototype
- Go to the Previous Level JavaScript Date Reference Manual