-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
56 lines (54 loc) · 1.2 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
<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>Digital clock</title>
<style>
body
{
background-color: azure;
}.clock
{
color: rgb(46, 29, 7);
position: absolute;
top: 35%;
left: 38%;
font-weight: bold;
font-size: 50px;
}
</style>
</head>
<body>
<div class="clock">
<span id="hours">00</span>
<span>:</span>
<span id="minutes">00</span>
<span>:</span>
<span id="seconds">00</span>
<span id="zones">AM</span>
</div>
<script>
function display()
{
var d=new Date();
var hours=d.getHours();
var minutes=d.getMinutes();
var seconds=d.getSeconds();
var zone=document.getElementById('zones');
if(hours >= 12){
zones.innerHTML = 'PM';
}else{
zones.innerHTML = 'AM';
}
if(hours > 12){
hours = hours - 12;
}
document.getElementById('hours').innerHTML=hours;
document.getElementById('minutes').innerHTML=minutes;
document.getElementById('seconds').innerHTML=seconds;
}
setInterval(display,10);
</script>
</body>
</html>