compare 2 time in format (HH:MM:SS) - Javascript Date Operation

Javascript examples for Date Operation:Date Format

Description

compare 2 time in format (HH:MM:SS)

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from www  .  j av a 2s .c  om

var now = new Date();

var deadline = new Date();
deadline.setHours(16);
deadline.setMinutes(0);

if( now > deadline ) {
    console.log('after deadline');
}
else {
    console.log('before deadline');
}

    }

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

Related Tutorials