Posted By

robnilas on 01/21/17


Tagged


Versions (?)

Continuous 24 hour Countdown


 / Published in: HTML
 

  1. <title>Countdown to Mid-night</title>
  2. <script type="text/javascript">
  3. // From: http://www.webdeveloper.com/forum/showthread.php?t=215504
  4.  
  5.  
  6. function ShowTimes() {
  7. var now = new Date();
  8. var hrs = 23-now.getHours();
  9. var mins = 59-now.getMinutes();
  10. var secs = 59-now.getSeconds();
  11. var str = '';
  12. str = now.toString();
  13. str += '<br>0 days '+hrs+' hours '+mins+' minutes '+secs+' seconds';
  14. document.getElementById('countdownToMidnight').innerHTML = str;
  15. }
  16. var _cntDown;
  17. function StopTimes() {
  18. clearInterval(_cntDown);
  19. }
  20.  
  21. </head>
  22. <body onload="_cntDown=setInterval('ShowTimes()',1000)">
  23. <div id="countdownToMidnight"></div>
  24. <button onclick="StopTimes()">Stop</button>
  25. </body>
  26. </html>

Report this snippet  

You need to login to post a comment.