Advertisement
ivandrofly

Javascript - Basic Clock

May 5th, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5. </head>
  6. <body>
  7. <p id="clock">Clock</p>
  8.  
  9. <script type="text/javascript">
  10.  
  11.     function printTime()
  12.     {
  13.         var now = new Date();
  14.         var hours = now.getHours();
  15.         var mins = now.getMinutes();
  16.         var seconds = now.getSeconds();
  17.         document.getElementById("clock").innerHTML = hours + ":" + mins + ":" + seconds;
  18.     }
  19.  
  20. setInterval("printTime()", 1000);
  21. </script>
  22. </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement