Program Code – Digital clock

This code is written in javascript. For that, you need to declare <script language=”javascript”> and the HTML file to be opened on your browser.

The code uses various built-in “Date & Time” functions in javascript.

It gets the current time and date from your operating system and shows it on an HTML page.

<html>
<head>
<title>Digital Clock</title>
</head>
<body  >
 <form >
   <script language="javascript">
	function f()
	{
        var Digital=new Date()
        var hours=Digital.getHours()
        var minutes=Digital.getMinutes()
        var sec=Digital.getSeconds() 
        /* The hours,minutes and seconds are get into the system time*/
        document.write("DIGI TIME <br>")
        document.write(hours+":"+minutes+":"+sec)
        setTimeout('location.href = location.href',1000);
	 }
	 window.onload=f() /* in this line the function is called*/
  </script>   
 </form>
</body>
</html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.