-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdigital_clock.html
106 lines (106 loc) · 2.21 KB
/
digital_clock.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
<!DOCTYPE html>
<html>
<head>
<title>Digital Clock</title>
<style>
.clock {
top: 45%;
left: 45%;
color: white;
font-family: sans-serif;
font-size: 60px;
letter-spacing: 7px;
text-align: center;
}
.d{
color: #9e9e9e;
border: 10px solid black;
border-radius: 25px;
}
ul li{
display: inline;
color: #9e9e9e;
}
ul{
word-spacing: 7px;
padding: 0px;
font-family: sans-serif;
text-align: center;
}
.outer{
border:25px solid #292e3a;
background-color: black;
width: 90%;
}
.corner{
position: fixed;
bottom: 15px;
text-align: center;
right: 60px;
border: 30px solid #dde3e7;
}
</style>
</head>
<body>
<header align="center">Created by Garvit Khurana 16BCE2054 ©</header>
<h1 align="center" style="font-size: 50px;">My Digital Clock</h1>
<div class="corner">
<div id="boundary" class="outer">
<ul>
<li id="Mon">Mon</li>
<li id="Tues">Tue</li>
<li id="Wed">Wed</li>
<li id="Thu">Thu</li>
<li id="Fri">Fri</li>
<li id="Sat">Sat</li>
<li id="Sun">Sun</li>
</ul>
<div id="clk" class="clock"></div>
<div id="dd" class="d"> </div>
</div>
<script>
function showTime()
{
var date = new Date();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var am_pm = date.getHours() >= 12 ? "PM" : "AM";
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
time = hours + ":" + minutes + ":" + seconds + " " + am_pm ;
document.getElementById("clk").innerText=time;
document.getElementById("clk").textContent=time;
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var curWeekDay = days[date.getDay()];
var day = curWeekDay;
switch(day)
{
case "Mon":
document.getElementById("Mon").style.color="#ffffff";
break;
case "Tue":
document.getElementById("Tue").style.color="#ffffff";
break;
case "Wed":
document.getElementById("Wed").style.color="#ffffff";
break;
case "Thu":
document.getElementById("Thu").style.color="#ffffff";
break;
case "Fri":
document.getElementById("Fri").style.color="#ffffff";
break;
case "Sat":
document.getElementById("Sat").style.color="#ffffff";
break;
case "Sun":
document.getElementById("Sun").style.color="#ffffff";
break;
}
setTimeout(showTime, 1000);
}
showTime();
</script>
</div>
</body>
</html>
</html>