Created
May 17, 2019 13:19
-
-
Save seabrizz/a9c5c9fedd2863ca44f9fec99969b5b9 to your computer and use it in GitHub Desktop.
timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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