The valueOf()
method returns
the milliseconds representation of the date
as the number of millisecond since midnight January 1, 1970 UTC.
valueOf() |
Yes | Yes | Yes | Yes | Yes |
dateObject.valueOf();
None.
A number representing the number of milliseconds between the date object and midnight January 1, 1970 UTC
var date1 = new Date(2007, 0, 1); //"January 1, 2007"
var date2 = new Date(2007, 1, 1); //"February 1, 2007"
console.log(date1.valueOf());
console.log(date2.valueOf());
The code above generates the following result.
< and > calls valueOf
method during the comparison.
var date1 = new Date(2007, 0, 1); //"January 1, 2007"
var date2 = new Date(2007, 1, 1); //"February 1, 2007"
console.log(date1 < date2); //true
console.log(date1 > date2); //false
The code above generates the following result.
+ sign converts Date value to millisecond.
var stop = + new Date();
console.log(stop);
The code above generates the following result.