X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript Date parse() Method

Date Object Reference JavaScript Date Object

Example

Return the number of milliseconds between January 1, 1970 and March 21, 2012:

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

The result of d will be:


Try it yourself »


Definition and Usage

The parse() method parses a date string and returns the number of milliseconds between the date string and midnight of January 1, 1970.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The parse() method is supported in all major browsers.


Syntax

Date.parse(datestring)

Parameter Values

Parameter Description
datestring Required. A string representing a date

Return Value

Type Description
Number Milliseconds between the specified date-time and midnight January 1, 1970

Technical Details

JavaScript Version: 1.0


More Examples

Example

Calculate the number of years between January 1, 1970 to 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);

result of y will be:


Try it yourself »


Date Object Reference JavaScript Date Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook