owlman

Clock | HTML

Jan 14th, 2016
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. function startTime() {
  3.     var today = new Date();
  4.     var h = today.getHours();
  5.     var m = today.getMinutes();
  6.     var s = today.getSeconds();
  7.     m = checkTime(m);
  8.     s = checkTime(s);
  9.     document.getElementById('txt').innerHTML =
  10.     h + ":" + m + ":" + s;
  11.     var t = setTimeout(startTime, 500);
  12. }
  13. function checkTime(i) {
  14.     if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
  15.    return i;
  16. }
  17. </script>
  18. </head>
  19.  
  20. <body onload="startTime()">
  21.  
  22. <div id="txt"></div>
RAW Paste Data