Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style>
- p {
- text-align: center;
- font-size: 60px;
- margin-top: 0px;
- }
- </style>
- </head>
- <body>
- <p id="countdown"></p>
- <script>
- function wait(ms) {
- var d = new Date();
- var d2 = null;
- do { d2 = new Date(); }
- while(d2-d < ms);
- }
- // Set the date we're counting down to
- var countDownDate = new Date("Aug 26, 2018 00:00:00 EDT").getTime();
- var times = ["Aug 26, 2018 18:44:00 EDT", "Aug 26, 2018 20:26:00 EDT", "Aug 26, 2018 22:09:00 EDT", "Aug 26, 2018 23:52:00 EDT", "Aug 27, 2018 01:35:00 EDT", "Aug 27, 2018 03:18:00 EDT", "Aug 27, 2018 05:01:00 EDT", "Aug 27, 2018 06:44:00 EDT", "Aug 27, 2018 08:27:00 EDT", "Aug 27, 2018 10:10:00 EDT", "Aug 27, 2018 11:53:00 EDT", "Aug 27, 2018 13:36:00 EDT"]
- var index = -1
- // Get todays date and time
- var now = new Date().getTime();
- // Find the distance between now and the count down date
- var distance = countDownDate - now;
- while (distance < 0) {
- index += 1
- countDownDate = new Date(times[index]).getTime();
- distance = countDownDate - now;
- }
- // Update the count down every 1 second
- var x = setInterval(function() {
- // Get todays date and time
- var now = new Date().getTime();
- // Find the distance between now and the count down date
- var distance = countDownDate - now;
- // Time calculations for days, hours, minutes and seconds
- var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
- var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
- var seconds = Math.floor((distance % (1000 * 60)) / 1000);
- // Output the result in an element with id="demo"
- document.getElementById("countdown").innerHTML = hours + "h "
- + minutes + "m " + seconds + "s ";
- console.log(distance)
- if (distance < 0) {
- document.getElementById("countdown").innerHTML = "Cube Time!";
- }
- if (distance < -19000) {
- index += 1
- countDownDate = new Date(times[index]).getTime();
- }
- }, 1000);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement