Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- var countDownDate = new Date("Jan 27, 2020 10:28:40").getTime();
- // Update the count down every 1 second
- var x = setInterval(function() {
- console.clear();
- // Get today's 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 days = Math.floor(distance / (1000 * 60 * 60 * 24));
- 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);
- // Console Log the time.
- var message = days + "d " + hours + "h "
- + minutes + "m " + seconds + "s ";
- console.log(message);
- // If the count down is finished, clear the interval
- if (distance < 0) {
- clearInterval(x);
- }
- //too dbah to write code to play an mp3 so I did a normal beep instead
- //electro_swing_penguin.mp3
- }, 1000);
- var finished = setInterval(function () {
- process.stdout.write('\x07');
- }, 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement