Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2. var countDownDate = new Date("Jan 27, 2020 10:28:40").getTime();
  3. // Update the count down every 1 second
  4. var x = setInterval(function() {
  5.     console.clear();
  6.   // Get today's date and time
  7.   var now = new Date().getTime();
  8.  
  9.   // Find the distance between now and the count down date
  10.   var distance = countDownDate - now;
  11.  
  12.   // Time calculations for days, hours, minutes and seconds
  13.   var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  14.   var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  15.   var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  16.   var seconds = Math.floor((distance % (1000 * 60)) / 1000);
  17.  
  18.   // Console Log the time.
  19.   var message = days + "d " + hours + "h "
  20.         + minutes + "m " + seconds + "s ";
  21.     console.log(message);
  22.    
  23.   // If the count down is finished, clear the interval
  24.     if (distance < 0) {
  25.         clearInterval(x);
  26.  
  27.     }
  28.      //too dbah to write code to play an mp3 so I did a normal beep instead
  29.      //electro_swing_penguin.mp3
  30. }, 1000);
  31.  
  32. var finished = setInterval(function () {
  33.     process.stdout.write('\x07');
  34. }, 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement