valueOf Method (Date)

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

Syntax


date.valueOf()  

Parameters

The date object is any instance of a Date.

Return Value

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

Example

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  

Requirements

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.