Convert a time to javascript-timestamps - Javascript Date Operation

Javascript examples for Date Operation:Timestamp

Description

Convert a time to javascript-timestamps

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(){/*ww  w. ja  v  a2 s  .  com*/
var sTime = '11:23';
var oDate = new Date();
oDate.setHours(
    parseInt(sTime.substr(0, 2), 10),
    parseInt(sTime.substr(3, 2), 10),
    0,
    0
);
var sTimestamp = oDate.getTime();
console.log(sTimestamp);
    }

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

Related Tutorials