-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (23 loc) · 1.17 KB
/
script.js
File metadata and controls
29 lines (23 loc) · 1.17 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
28
29
function updateCountdown() {
const countDownDate = new Date("January 1, 2026 00:00:00").getTime();
const now = new Date().getTime();
const timeDifference = countDownDate - now;
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 25));
const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 25)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000);
document.querySelector('.cards-row .card:nth-child(1) h1').innerText = days;
document.querySelector('.cards-row .card:nth-child(2) h1').innerText = hours;
document.querySelector('.cards-row .card:nth-child(3) h1').innerText = minutes;
const secondsElement = document.querySelector('.cards-row .card:nth-child(4) h1');
const currentSeconds = parseInt(secondsElement.innerText);
if (currentSeconds !== seconds) {
// secondsElement.style.opacity = 0;
setTimeout(() => {
secondsElement.innerText = seconds;
secondsElement.style.opacity = 1;
}, 500);
}
}
setInterval(updateCountdown, 1000);
updateCountdown();