Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
  2. function GetCount(){
  3. var d = new Date();
  4. var dateFuture = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 16, 00, 00);
  5. dateNow = new Date(); //grab current date
  6. amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
  7.  
  8. day = "morgen";
  9. // time is already past
  10. if(amount < 0){
  11. dateFuture = new Date(d.getFullYear(), d.getMonth(), (d.getDate()), 23, 59, 59);
  12. amount = dateFuture.getTime() - dateNow.getTime();
  13. day = "overmorgen";
  14. }
  15. // date is still good
  16.  
  17. days=1;hours=0;mins=0;secs=0;out="";
  18.  
  19. amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
  20. //days=Math.floor(amount/86400);//days
  21. amount=amount%86400;
  22.  
  23. hours=Math.floor(amount/3600);//hours
  24. amount=amount%3600;
  25.  
  26. mins=Math.floor(amount/60);//minutes
  27. amount=amount%60;
  28.  
  29. secs=Math.floor(amount);//seconds
  30.  
  31. document.getElementById('countbox').innerHTML=n(hours) + ":" + n(mins)+ ":" + n(secs);
  32. document.getElementById('countbox-day').innerHTML=day;
  33. setTimeout("GetCount()", 1000);
  34.  
  35. }
  36.  
  37. function n(n){
  38. return n > 9 ? "" + n: "0" + n;
  39. }
  40. window.onload=function(){GetCount();}//call when everything has loaded
  41.  
  42. //-->
  43. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement