Get Current Date and Time in JavaScript



To get current date and time in JavaScript, use the Date object.

Example

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

<!DOCTYPE html>
<html>
   <body>
      <p id="currentDate"></p>
      <script>
         document.getElementById("currentDate").innerHTML = Date();
      </script>
   </body>
</html>
Updated on: 2020-06-16T13:25:45+05:30

448 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements