Advertisement
cdsatrian

tampilkan waktu server

Nov 1st, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. var today=new Date('<?php echo date('F j, Y h:i:s')?>');
  6. function startTime()
  7. {
  8.  var today1 = new Date();
  9.  today1.setDate(today.getSeconds()+1);
  10.  var h=today1.getHours();
  11.  var m=today1.getMinutes();
  12.  var s=today1.getSeconds();
  13. // add a zero in front of numbers<10
  14.   m=checkTime(m);
  15.   s=checkTime(s);
  16.   document.getElementById('txt').innerHTML=h+":"+m+":"+s;
  17.   t=setTimeout(function(){startTime()},1000);
  18. }
  19.  
  20. function checkTime(i)
  21. {
  22.   i=(i<10)?"0" + i:i;
  23.   return i;
  24. }
  25. </script>
  26. </head>
  27.  
  28. <body onload="startTime()">
  29. <div id="txt"></div>
  30. </body>
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement