Make Javascript to change datetime format - Javascript Date

Javascript examples for Date:getMonth

Description

Make Javascript to change datetime format

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 .j  ava2  s  .co m
var d = new Date("2013-06-07T19:53:00.001+07:00");
var date = d.getDate();
var month = d.getMonth() + 1;
var year = d.getFullYear();
var hours = d.getHours();
var mins = d.getMinutes();
var datestring = month + "/" + date + "/" + year + " at " + hours + ":" + mins;
console.log(datestring);
    }

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

Related Tutorials