How to get current date and time using JavaScript?

JavascriptWeb DevelopmentFront End Technology

To get current date and time using JavaScript, use the Date() method. JavaScript Date() method returns today's date and time and does not need any object to be called.

Example

You can try to run the following code to get current date and time −

Live Demo

<html>
   <head>
      <title>JavaScript Date Method</title>
   </head>
   <body>
      <script>
         var dt = Date();
         document.write("Date and Time : " + dt );
      </script>
   </body>
</html>

Output

Date and Time : Mon May 28 2018 10:16:33 GMT+0530 (India Standard Time)
raja
Published on 13-Feb-2018 12:45:35
Advertisements