-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
49 lines (47 loc) · 1.41 KB
/
index.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
<!DOCTYPE HTML>
<html>
<head>
<title>TIMER</title>
<style>
p {
text-align: center;
font-size: 80px;
font-family: "Fira Code Retina" ;
font-style: oblique;
color: white;
}
body{
background-image: url('cake.jpg');
background-size: cover;
}
</style>
</head>
<body>
<p id = "show" ></p>
<script>
var t = setInterval(myTimer,1000);
function myTimer(){
var tillDate = new Date("July 21,2017 00:00:00").getTime();
var toDay = new Date().getTime();
var diff = tillDate - toDay;
var days = Math.floor(diff/(1000*60*60*24));
var hours = Math.floor((diff%(1000*60*60*24))/(1000*60*60));
var mins = Math.floor((diff%(1000*60*60))/(1000*60));
var sec = Math.floor((diff%(1000*60))/1000);
days = checkTime(days);
hours = checkTime(hours);
mins = checkTime(mins);
sec = checkTime(sec);
document.getElementById("show").innerHTML= days + "d " + hours + "h " + mins + "m " + sec + "s to go!!" ;
if(diff<0){
clearInterval(t);
document.getElementById("show").innerHTML = "HAPPY BIRTHDAY TO SOMEONE WHO IS FOREVER YOUNG";
}
}
function checkTime(x) {
if (x < 10) {x = "0" + x}; // adding zero in front of numbers if < 10
return x;
}
</script>
</body>
</html>