Skip to content

Commit 6573432

Browse files
authored
Create time_left_in_2021.html
1 parent bfdd479 commit 6573432

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

time_left_in_2021.html

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link href="https://fonts.googleapis.com/css2?family=Fjalla+One&display=swap" rel="stylesheet">
7+
8+
<title>Time Left in 2020</title>
9+
<style>
10+
11+
body{
12+
text-align: center;
13+
font-family: 'Fjalla One', sans-serif;
14+
background-color: #fff;
15+
}
16+
.box{
17+
display: inline-block;
18+
display: inline-block;
19+
color: #fff;
20+
padding: 10px;
21+
border-radius: 5px;
22+
}
23+
#days{
24+
background-color:#0f4d4f;
25+
}
26+
#hours{
27+
background-color:#4CAF50;
28+
}
29+
#minutes{
30+
background-color:#76250b;
31+
}
32+
h2{
33+
display: inline-block;
34+
margin-right: 10px;
35+
}
36+
37+
38+
</style>
39+
</head>
40+
<body>
41+
<div id="counter">
42+
<h2>
43+
Time left in 2021
44+
</h2>
45+
46+
<h2 class="box" id="days"></h2>
47+
<h2 class="box" id="hours"></h2>
48+
<h2 class="box" id="minutes"></h2>
49+
50+
</div>
51+
52+
53+
54+
55+
56+
<script>
57+
function CountDownTimer (date) {
58+
left_days = document.getElementById("days");
59+
left_hours = document.getElementById("hours");
60+
left_minutes = document.getElementById("minutes");
61+
62+
end = new Date(date);
63+
_second = 1000;
64+
_minute = _second * 60;
65+
_hour = _minute * 60;
66+
_day = _hour * 24;
67+
}
68+
function showRemaining (){
69+
now = new Date();
70+
distance = end - now;
71+
distance2 = new Date("01/01/2021 00:00 AM") - now
72+
if (distance <= 0 ){
73+
clearInterval (timer)
74+
document.getElementById("counter").innerHTML = "<h2>Nothing! It's Over<h2>";
75+
return
76+
}
77+
else if (distance2 > 0 ){
78+
clearInterval (timer)
79+
document.getElementById("counter").innerHTML = "<h2>2021 Didn't Start yet!</h2>";
80+
return
81+
}
82+
days = Math.floor(distance / _day)
83+
hours = Math.floor((distance % _day) / _hour)
84+
minutes = Math.floor((distance % _hour) / _minute)
85+
left_days.innerHTML = days + " days "
86+
left_hours.innerHTML = hours + " hours "
87+
left_minutes.innerHTML = minutes + " mins "
88+
}
89+
90+
91+
timer = setInterval (showRemaining, 1)
92+
CountDownTimer( "01/01/2022 00:00 AM")
93+
</script>
94+
</body>
95+
</html>

0 commit comments

Comments
 (0)