Untitled
2 weeks ago in Plain Text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Montserrat:900">
<title>Document</title>
<style>

body{
background-color: white;
}

#timer {
color: #eeeeee;
text-align: center;
text-transform: uppercase;
font-family: 'Lato', sans-serif;
font-size: .7em;
letter-spacing: 5px;
}

.days, .hours, .minutes, .seconds {
display: inline-block;
padding: 20px;
width: 100px;
border-radius: 5px;
}

.days {
background: #EF2F3C;
}

.hours {
background: #eeeeee;
color: #183059;
}

.minutes {
background: #276FBF;
}

.seconds {
background: #F0A202;
}

.numbers {
font-family: 'Montserrat', sans-serif;
color: #183059;
font-size: 4em;
text-align: center;
}

.white {
position: absolute;
background: #eeeeee;
height: 85px;
width: 75px;
left: 30%;
top: 2%;
}

.red {
position: absolute;
background: #EF2F3C;
left: 18%;
top: 9%;
height: 65px;
width: 70px;

}

.blue {
position: absolute;
background: #276FBF;
height: 80px;
width: 80px;
left: 60%;
top: 5%;


}


</style>
</head>
<body>

<div id="timer">

<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>

</div>

</body>
<script>
const year = new Date().getFullYear();
const myDate = new Date('Oct 01, 2020 00:00:00');
console.log(myDate);

// countdown
let timer = setInterval(function() {

// get today's date
const today = new Date().getTime();

// get the difference
const diff = myDate - today;

// math
let days = Math.floor(diff / (1000 * 60 * 60 * 24));
let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((diff % (1000 * 60)) / 1000);

// display
document.getElementById("days").innerHTML=days
document.getElementById("hours").innerHTML=hours
document.getElementById("minutes").innerHTML=minutes
document.getElementById("seconds").innerHTML=seconds



}, 1);
</script>
</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