Format time from local time - Javascript Date Operation

Javascript examples for Date Operation:Time Format

Description

Format time from local time

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  w  w  w . jav a  2 s.c  o  m*/
var dateLocal = new Date();
var dateString = (dateLocal.getMonth() + 1) 
    + "/" + dateLocal.getDate() 
    + "/" + dateLocal.getFullYear()+" "+dateLocal.getHours() 
    + ":" + dateLocal.getMinutes() + ":" + dateLocal.getSeconds() ;
console.log(dateString);
    }

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

Related Tutorials