Compare two date/time stamps - Javascript Date Operation

Javascript examples for Date Operation:Date Compare

Description

Compare two date/time stamps

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
var d1 = "2018-03-02T15:30:18-08:00";
var d2 = "2018-03-02T15:36:05-08:00";
if (new Date(d1) < new Date(d2)) {//from  ww  w.jav  a2  s  .co  m
    console.log('newer')
}

      </script>  
   </body>
</html>

Related Tutorials