Javascript Data Type How to - Compare Javascript Date Objects








Question

We would like to know how to compare Javascript Date Objects.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from   w  ww  .  j ava  2 s .  c om-->
    var expirationDate = new Date("Wed, 16 Oct 2013 15:42:53 GMT");
    var now = new Date();
    document.writeln(now > expirationDate);
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: