Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

valueOf Method (Date)

Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.

date.valueOf()

The date object is any instance of a Date.

The stored time value in milliseconds since midnight, January 1, 1970 UTC. This is the same value as getTime.

The following example illustrates the use of the valueOf method with a date.

var myDate = new Date();
myDate.setFullYear(2100, 5, 5);
if (myDate.getTime() == myDate.valueOf())
    document.write("values are the same");
else
    document.write("values are different");

// Output: values are the same 

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Show:
© 2015 Microsoft