Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Date.parse Function (JavaScript)

Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.

Date.parse(dateVal) 

The required dateVal argument is either a string containing a date or a VT_DATE value retrieved from an ActiveX object or other object. For information about date strings that the Date.parse function can parse. see Formatting Date and Time Strings (JavaScript).

The Date.parse function returns an integer value representing the number of milliseconds between midnight, January 1, 1970 and the date supplied in dateVal.

The following example illustrates the use of the Date.parse function.

var dateString = "November 1, 1997 10:15 AM";
var mSec = Date.parse(dateString)

The following example returns the difference between the date provided and 1/1/1970.

function GetTimeTest(testDate) {
    var minMilli = 1000 * 60;    
    var hrMilli = minMilli * 60;
    var dyMilli = hrMilli * 24;

    var ms = Date.parse(testDate);
    var days = Math.round(ms / dyMilli);

    var s = "";
    s += "There are ";
    s += days + " days ";
    s += "between 01/01/1970 and " + testDate;
    return (s);
}

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Date Object (JavaScript)

Community Additions

Show:
© 2015 Microsoft