-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (19 loc) · 953 Bytes
/
script.js
File metadata and controls
27 lines (19 loc) · 953 Bytes
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
function updateCountdown() {
const currentDate = new Date();
const targetDate = new Date('2024-06-11T22:59:59');
const difference = targetDate - currentDate;
const days = Math.floor(difference / (1000 * 60 * 60 * 24))
const hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((difference % (1000 * 60)) / 1000);
document.querySelector('#days').innerText = days + 'd';
document.querySelector('#hours').innerText = hours + 'h';
document.querySelector('#minutes').innerText = minutes + 'm';
document.querySelector('#seconds').innerText = seconds + 's';
const interval = setInterval(updateCountdown, 1000);
if(difference < 0) {
clearInterval(interval);
document.querySelector('#timer').innerText = "The event has started!";
}
}
updateCountdown();