DEV Community

Zoya Khan
Zoya Khan

Posted on

HTML Code for Date and Time Tool

<!DOCTYPE html>
<html>
  <head>
    <title>Current Date and Time</title>
  </head>
  <body>
    <h1>Current Date and Time</h1>
    <p>
      The current date and time is: <span id="datetime"></span>
    </p>
    <script>
      var datetimeElement = document.getElementById("datetime");
      var now = new Date();
      datetimeElement.textContent = now.toString();
    </script>
  </body>
</html>

Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
zoyakhanblogger profile image
Zoya Khan

thank you so much :)

Retry later
Retry later