Created
August 2, 2021 13:04
-
-
Save MoisesTedeschi/34359f4ccd81f1e47da5b8ec7d3ac22c to your computer and use it in GitHub Desktop.
Contador zerando quando chega na data limite.
This file contains hidden or 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
<div class="contagem"> | |
Faltam apenas | |
<mark><span class="numero" id="days"></span> DIAS, <span id="hours"></span> HORAS, | |
<span class="numero" id="minutes"></span> MINUTOS</mark> E <mark><span class="numero" id="seconds"></span> SEGUNDOS</mark> | |
</div> | |
<script> | |
var countDownDate = new Date("Aug 02, 2021 20:00:00").getTime(); | |
var countdown = setInterval(function() { | |
var now = new Date().getTime(); | |
var difference = countDownDate - now; | |
var days = Math.floor(difference / (1000 * 60 * 60 * 24)); | |
var hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | |
var minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60)); | |
var seconds = Math.floor((difference % (1000 * 60)) / 1000); | |
if (difference < 0) { | |
clearInterval(countdown); | |
days = 0, hours = 0, minutes = 0, seconds = 0; | |
} | |
document.getElementById("days").innerText = days; | |
document.getElementById("hours").innerText = hours; | |
document.getElementById("minutes").innerText = minutes; | |
document.getElementById("seconds").innerText = seconds; | |
}, 1000); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment