Date valueOf()
The valueOf() method returns the milliseconds representation of the date.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var date1 = new Date(2007, 0, 1); //"January 1, 2007"
var date2 = new Date(2007, 1, 1); //"February 1, 2007"
document.writeln(date1.valueOf());
document.writeln(date2.valueOf());
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var date1 = new Date(2007, 0, 1); //"January 1, 2007"
var date2 = new Date(2007, 1, 1); //"February 1, 2007"
document.writeln(date1 < date2); //true
document.writeln(date1 > date2); //false
</script>
</head>
<body>
</body>
</html>
< and > calls valueOf method during the comparison.