-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (29 loc) · 1.01 KB
/
script.js
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
30
31
32
33
34
// Set the countdown date and time
var countDownDate = new Date("August 24, 2023 15:00:00").getTime();
// Update the countdown every second
var countdown = setInterval(function () {
// Get current date and time
var now = new Date().getTime();
// Calculate the remaining time
var distance = countDownDate - now;
// Calculate days, hours, minutes, and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the countdown
document.getElementById("countdown").innerHTML =
days +
" DAYS " +
hours +
" HOURS " +
minutes +
" MINUTES " +
seconds +
" SECONDS";
// If the countdown is finished, display a message
if (distance < 0) {
clearInterval(countdown);
document.getElementById("countdown").innerHTML = "Event has started!";
}
}, 1000);