-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
85 lines (66 loc) · 1.62 KB
/
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
<!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>JS - Digital Clock</title>
<style>
body{
background-color: black;
color: turquoise;
text-align: center;
font-size: xx-large;
}
.clock{
background-color: black;
color: white;
font-size: 100px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
padding-bottom: 90px;
}
button{
color: black;
font-family: cursive;
cursor: pointer;
font-size: xx-large;
background-color: cadetblue;
}
</style>
</head>
<body>
<h1>Digital Clock</h1>
<div id="MyClockDisplay" class="clock">
</div>
<script type="text/javascript">
function showTime(){
var date = new Date();
var h = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
var session = "AM";
if(h == 0){
h = 12;
}
if(h > 12){
h = h - 12;
session = "PM"
}
if(h < 10){
h = "0" +h;
}
if(m < 10){
m = "0" + m;
}
if(s < 10){
s = "0" + s;
}
var time = h + ":" + m + ":" + s + "" + session;
document.getElementById("MyClockDisplay").innerText = time;
document.getElementById("MyClockDisplay").textContent = time;
setTimeout(showTime, 1000);
}
showTime();
</script>
</body>
</html>