Get current date - Javascript Date

Javascript examples for Date:constructor

Description

Get current date

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(){/* w ww.  j  a  va2  s  .co  m*/


var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var output = d.getFullYear() + '/' + month + '/' + day;
console.log(output);


    }

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

Related Tutorials