Guest User

Untitled

a guest
Nov 14th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta name="description" content="counter">
  5. <style>
  6. p {
  7. text-align: center;
  8. font-size: 60px;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13.  
  14. <p id="demo"></p>
  15.  
  16. <script>
  17. // Set the date we're counting down to
  18. // var countDownDate = new Date("Jan 5, 2018 15:37:25").getTime();
  19. var now = new Date()
  20. var countDownDate = new Date(now.getTime() + 1*60000);
  21. // Update the count down every 1 second
  22. var x = setInterval(function() {
  23.  
  24. // Get todays date and time
  25. // var now = new Date()
  26.  
  27. // Find the distance between now an the count down date
  28. var distance = countDownDate - now;
  29. countDownDate -=1000
  30.  
  31. // Time calculations for days, hours, minutes and seconds
  32. var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  33. var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  34. var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  35. var seconds = Math.floor((distance % (1000 * 60)) / 1000);
  36.  
  37. // Output the result in an element with id="demo"
  38. document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";
  39.  
  40. // If the count down is over, write some text
  41. if (distance < 0) {
  42. clearInterval(x);
  43. document.getElementById("demo").innerHTML = "EXPIRED";
  44. }
  45. }, 1000);
  46. </script>
  47.  
  48.  
  49. <script id="jsbin-source-html" type="text/html"><!DOCTYPE HTML>
  50. <html>
  51. <head>
  52. <meta name="description" content="counter">
  53. <style>
  54. p {
  55. text-align: center;
  56. font-size: 60px;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61.  
  62. <p id="demo"></p>
  63.  
  64. <script>
  65. // Set the date we're counting down to
  66. // var countDownDate = new Date("Jan 5, 2018 15:37:25").getTime();
  67. var now = new Date()
  68. var countDownDate = new Date(now.getTime() + 1*60000);
  69. // Update the count down every 1 second
  70. var x = setInterval(function() {
  71.  
  72. // Get todays date and time
  73. // var now = new Date()
  74.  
  75. // Find the distance between now an the count down date
  76. var distance = countDownDate - now;
  77. countDownDate -=1000
  78.  
  79. // Time calculations for days, hours, minutes and seconds
  80. var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  81. var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  82. var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  83. var seconds = Math.floor((distance % (1000 * 60)) / 1000);
  84.  
  85. // Output the result in an element with id="demo"
  86. document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";
  87.  
  88. // If the count down is over, write some text
  89. if (distance < 0) {
  90. clearInterval(x);
  91. document.getElementById("demo").innerHTML = "EXPIRED";
  92. }
  93. }, 1000);
  94. <\/script>
  95.  
  96. </body>
  97. </html>
  98. </script>
  99.  
  100. </body>
  101. </html>
Add Comment
Please, Sign In to add comment