-
Notifications
You must be signed in to change notification settings - Fork 0
/
countdown.html
115 lines (97 loc) · 3.23 KB
/
countdown.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Lato&family=Righteous" rel="stylesheet">
<title>Countdown</title>
<style type="text/css">
.container {
color: #efe9ae;
display: flex;
text-align: center;
text-transform: uppercase;
font-family: 'Righteous', cursive;
font-size: 3vw;
letter-spacing: .2em;
}
.days,
.hours,
.minutes,
.seconds {
margin: 1%;
display: inline-block;
padding: .2em;
min-width: 20vw;
max-width: fit-content;
border-radius: 1em;
}
.days {
background: #6a4c93;
}
.hours {
background: #1982c4;
}
.minutes {
background: #8ac926;
}
.seconds {
background: #ff595e;
}
.numbers {
color: #ffc300;
font-family: 'Lato', sans-serif;
font-weight: 700;
font-size: 4em;
}
</style>
</head>
<body>
<div class="container">
<div class="days">
<div id="days" class="numbers"> </div>days
</div>
<div class="hours">
<div id="hours" class="numbers"> </div>hours
</div>
<div class="minutes">
<div id="minutes" class="numbers"> </div>minutes
</div>
<div class="seconds">
<div id="seconds" class="numbers"> </div>seconds
</div>
</div>
</body>
<script>
// Set the date we're counting down to
var countDownDate = new Date("Sep 17, 2023 00:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function () {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for 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 result
document.getElementById("days").innerHTML = days
document.getElementById("hours").innerHTML = hours
document.getElementById("minutes").innerHTML = minutes
document.getElementById("seconds").innerHTML = seconds
// If the count down is over
if (distance < 0) {
clearInterval(x);
document.getElementById("days").innerHTML = "EX";
document.getElementById("hours").innerHTML = "PI";
document.getElementById("minutes").innerHTML = "RE";
document.getElementById("seconds").innerHTML = "D";
}
}, 1000);
</script>
</html>
<!-- Terinspirasi dari
- https://blog.shorouk.dev/notion-widgets-gallery/notion-widget-count-down/
- https://www.w3schools.com/howto/howto_js_countdown.asp -->