Parse string in format of "2018-03-02T15:30:18-08:00" to Date - Javascript String Operation

Javascript examples for String Operation:String Parse

Description

Parse string in format of "2018-03-02T15:30:18-08:00" to Date

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   w ww  .  ja  v  a 2s  .c  o m
    console.log('newer')
}

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

Related Tutorials