-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (96 loc) · 2.83 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New year timer</title>
<style>
*{
padding:0;
margin:0;
}
body{
background:url(nature.jpeg);
background-image: no-repeat;
background-size:cover;
height:100vh;
width:100vw;
display:flex;
justify-content: center;
align-items: center;
color:white;
}
.container{
height:70vh;
width:70vw;
background:rgba(green, black,black, 0.7);
border-radius:10px;
box-shadow: -2px -2px 5px 11px rgba(white,white, white,0.7);
align-items: center;
justify-content: center;
display: flex;
flex-direction:column ;
}
.container .timerContainer{
display:flex;
margin:20px
}
#h1{
font-size:50px
}
.timer{
margin: 0 20px;
font-size:40px;
text-align:center
}
</style>
</head>
<body>
<div class="container">
<h1 id="h1"> New Year timer</h1>
<div class = "timerContainer">
<div class="timer">
<h3 id="days">00</h3>
<p>days</p>
</div>
<div class="timer">
<h3 id="hour">00</h3>
<p>hour</p>
</div>
<div class="timer">
<h3 id="minute">00</h3>
<p>minute</p>
</div>
<div class="timer">
<h3 id="second">00</h3>
<p>second</p>
</div>
</div>
</div>
<script>
const days = document.getElementById("days");
const hour = document.getElementById("hour");
const minute = document.getElementById("minute");
const second = document.getElementById("second");
const currentYear = new Date().getFullYear();
const newYearTIme = new Date(`January 1 ${currentYear +1} 00:00:00`);
function updateTime(){
const currentTime = new Date();
const TimeLeft = newYearTIme - currentTime;
console.log(TimeLeft);
// till here we are gettting the time left in seconds
// now we have to update the time in day , hours , minutes
const d = Math.floor(TimeLeft/1000/60/60/24);
const h = Math.floor(TimeLeft/1000/60/60)%24;
const m = Math.floor(TimeLeft/1000/60)%60;
const s = Math.floor(TimeLeft/1000)%60;
days.innerHTML = d;
hour.innerHTML = h<10?"0"+h:h;
minute.innerHTML = m<10?"0"+m:m;
second.innerHTML = s<10?"0"+s:s;
}
setInterval(updateTime , 1000);
</script>
</body>
</html>