Skip to content

Instantly share code, notes, and snippets.

@seabrizz
Created May 17, 2019 13:19
Show Gist options
  • Save seabrizz/a9c5c9fedd2863ca44f9fec99969b5b9 to your computer and use it in GitHub Desktop.
Save seabrizz/a9c5c9fedd2863ca44f9fec99969b5b9 to your computer and use it in GitHub Desktop.
timer
//html
<p id="time"></p>
//js
let countDownDate = new Date("May 17, 2019 16:00:00").getTime();
let x = setInterval(function() {
let now = new Date().getTime();
let distance = countDownDate - now;
let days = Math.floor(distance / (1000 * 60 * 60 * 24));
let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("time").innerHTML = days + "д " + hours + "г "
+ minutes + "хв " + seconds + "с ";
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment