How to get current date and time in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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>
raja
Published on 01-Feb-2018 16:28:52
Advertisements