forked from jakubgania/countdown-timer-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.html
139 lines (125 loc) · 5.28 KB
/
timer.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="robots" content="noindex,nofollow">
<title>
RAGNARRÖK
</title>
<link href="https://fonts.googleapis.com/css2?family=Major+Mono+Display&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Major Mono Display', monospace;
background-color: #000000;
}
.text {
font-size: 3.4vw;
text-align: left;
margin-left: 20px;
color: #f2f2f2;
letter-spacing: 2px;
margin-top: 10px;
margin-bottom: 10px;
}
.section
{
height: 48px;
line-height: 48px;
}
.border-bottom-class
{
border-bottom: 1px solid #8c8c8c;
}
.days-color {
}
.hours-color {
}
.minutes-color {
}
.seconds-color {
}
.container {
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<!-- Display the countdown timer in an element -->
<div class="container">
<div class="section">
<div class="text">
current date:
</div>
</div>
<div class="section" style="margin-bottom: 60px;">
<div id="current-date" class="text"></div>
</div>
<div class="section">
<div class="text">
end date:
</div>
</div>
<div class="section" style="margin-bottom: 60px;">
<div id="end-date" class="text"></div>
</div>
<div class="section">
<div class="text">
time left:
</div>
</div>
<div class="section border-bottom-class">
<div id="demo" class="text"></div>
</div>
<div class="section border-bottom-class">
<div id="days" class="text days-color"></div>
</div>
<div class="section border-bottom-class">
<div id="hours" class="text hours-color"></div>
</div>
<div class="section border-bottom-class">
<div id="minutes" class="text minutes-color"></div>
</div>
<div class="section">
<div id="seconds" class="text seconds-color"></div>
</div>
</div>
<script>
// Set the date we're counting down to
var datetime = "Jan 01 2026 00:00:00"
var countDownDate = new Date(datetime).getTime();
document.getElementById("end-date").innerHTML = datetime
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var time = new Date()
var now = time.getTime();
currentDate = String(time).slice(4, 25)
document.getElementById("current-date").innerHTML = currentDate
// 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 in the element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
document.getElementById("days").innerHTML = days + " days";
document.getElementById("hours").innerHTML = Math.floor((distance / (1000 * 60 * 60))) + " hours";
document.getElementById("minutes").innerHTML = Math.floor((distance / (1000 * 60))) + " minutes";
document.getElementById("seconds").innerHTML = Math.floor((distance / 1000)) + " seconds";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
</script>
</body>
</html>