Skip to content

Commit bfdd479

Browse files
authored
Create time_left_in_2020.html
1 parent c5d920d commit bfdd479

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

time_left_in_2020.html

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
<h2>
42+
Time left in 2020
43+
</h2>
44+
45+
<h2 class="box" id="days"></h2>
46+
<h2 class="box" id="hours"></h2>
47+
<h2 class="box" id="minutes"></h2>
48+
49+
50+
51+
52+
<script>
53+
function CountDownTimer (date) {
54+
left_days = document.getElementById("days");
55+
left_hours = document.getElementById("hours");
56+
left_minutes = document.getElementById("minutes");
57+
58+
end = new Date(date);
59+
_second = 1000;
60+
_minute = _second * 60;
61+
_hour = _minute * 60;
62+
_day = _hour * 24;
63+
}
64+
function showRemaining (){
65+
now = new Date();
66+
distance = end - now;
67+
if (distance <= 0){
68+
clearInterval (timer)
69+
selector.innerHTML = "Nothing! It's Over";
70+
return
71+
}
72+
days = Math.floor(distance / _day)
73+
hours = Math.floor((distance % _day) / _hour)
74+
minutes = Math.floor((distance % _hour) / _minute)
75+
left_days.innerHTML = days + " days "
76+
left_hours.innerHTML = hours + " hours "
77+
left_minutes.innerHTML = minutes + " mins "
78+
}
79+
80+
81+
timer = setInterval (showRemaining, 1000)
82+
CountDownTimer( "01/01/2021 00:00 AM")
83+
</script>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)