-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfile.html
54 lines (47 loc) · 1.53 KB
/
file.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<title>Countdown Timer</title>
<style>
#countdown {
font-size: 2em;
font-weight: bold;
text-align: center;
margin-top: 1em;
padding: 0.5em;
background-color: #f2f2f2;
border-radius: 0.5em;
}
#countdown.expired {
background-color: #ffcccc;
}
</style>
</head>
<body>
<div id="countdown"></div>
<script>
// Set the date to countdown to
var countDownDate = new Date("2023-03-01T00:00:00").getTime();
// Update the countdown every second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Calculate the time remaining
var distance = countDownDate - now;
// Calculate the days, hours, minutes and seconds remaining
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 in the element with id="countdown"
document.getElementById("countdown").innerHTML = "Countdown: " + days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the countdown is finished, display "EXPIRED"
if (distance < 0) {
clearInterval(x);
document.getElementById("countdown").innerHTML = "EXPIRED";
}
}, 1000);
</script>
</body>
</html>