Adding setUTCDate() to format Date time - Javascript Date

Javascript examples for Date:setUTCDate

Description

Adding setUTCDate() to format Date 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(){/*  ww w .ja  v  a  2s  .c o  m*/
function checkTime(i) {
    if(i<10) 
       i='0'+i;
    return i;
}

var d = new Date();
var now = checkTime(d.getUTCHours()) + ':' +
    checkTime(d.getUTCMinutes()) + ':' +
    checkTime(d.getUTCSeconds());

console.log(now);

    }

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

Related Tutorials