English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Date.parse() method

 JavaScript Date Object

Date.parse() method accepts a date string (e.g., "Jul 30, 1992)), and returns1970 years1Month1Milliseconds since midnight of the day.

This feature is very useful for setting date values based on string values, such as combining the setTime() method with a Date object.

Since parse() is a static method of Date, you should always use it as Date.parse().

Syntax:

Date.parse(dateString)
var d = Date.parse("July 30, 1992");
Test and see‹/›

Browser compatibility

All browsers fully support the parse() method:

Method
parse()IsIsIsIsIs

Parameter Value

ParameterDescription
dateStringString representing a date

Technical Details

Return value:Since1970 years1Month1Milliseconds since midnight of the day
JavaScript version:ECMAScript 1

More examples

Calculate from1970 years1Month1Day to1992Year7Month3Number of years between 0 days:

function myFunc() {
var d = Date.parse("July 30, 1992");
var minutes = 1000 * 60;
var hours = minutes * 60;
var days = hours * 24;
var years = days * 365;
var ans = Math.round(d / years);
document.getElementById('result').innerHTML = ans;
}
Test and see‹/›

 JavaScript Date Object