HOW TO DISPLAY CURRENT DATE AND TIME IN HTML ?

 

 In this page you can able to learn that how to display live date and time in HTML page. The steps are given below 

  • First we have to create an html page.
  • At next we have to use the html tag (<html></html>).
  • Then  we have to use head tag.
  • Inside the head tag we have to use the title tag. Title tag is used to display the title of the web page.
  • Then we can give the code in the body section.
  • Inside the body tag we have to create a button with the name of  DATE AND TIME.
  • In button tag we have to use the onclick method.
  • Then we have to create empty paragraph tag with id (display) to display the date and time.
  • Then  we need the script tag to make the code.

Program:

<html>
<head>
    <title>Dispaly date and time</title>
    
</head>
    
<body>
    <button type="submit" onclick="displaytime()">DATE AND TIME</button>
    <p id="display"></p>
</body>
    <script>
    function displaytime(){
        document.getElementById('display').innerHTML=Date();
    }
    
    </script>
</html>

OUTPUT:

Before clicking DATE AND TIME button


After Clicking The DATE AND TIME button



To click the live preview of the above program click the demo button



0 تعليقات

إرسال تعليق

Post a Comment (0)

أحدث أقدم