-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (22 loc) · 1.11 KB
/
script.js
File metadata and controls
27 lines (22 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const targetDate = new Date("October 15, 2026 00:00:00").getTime();
function atualizarContador() {
const agora = new Date().getTime();
const distancia = targetDate - agora;
if (distancia <= 0) {
document.getElementById("dias").textContent = "000";
document.getElementById("horas").textContent = "00";
document.getElementById("minutos").textContent = "00";
document.getElementById("segundos").textContent = "00";
return;
}
const dias = Math.floor(distancia / (1000 * 60 * 60 * 24));
const horas = Math.floor((distancia % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutos = Math.floor((distancia % (1000 * 60 * 60)) / (1000 * 60));
const segundos = Math.floor((distancia % (1000 * 60)) / 1000);
document.getElementById("dias").textContent = String(dias).padStart(3, "0");
document.getElementById("horas").textContent = String(horas).padStart(2, "0");
document.getElementById("minutos").textContent = String(minutos).padStart(2, "0");
document.getElementById("segundos").textContent = String(segundos).padStart(2, "0");
}
setInterval(atualizarContador, 1000);
atualizarContador();