How to get current date and time using JavaScript?


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)

Updated on: 18-Jun-2020

345 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements