-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
49 lines (46 loc) · 1.19 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="clock.css">
<title>Document</title>
</head>
<body>
<div id="title">
<h1 id="title1">Time</h1>
<h1><span id="hours">00</span>
<span>:</span>
<span id="minutes">00</span>
<span>:</span>
<span id="seconds">00</span>
<span id="day">AM</span></h1>
</div>
<script>
function time()
{
let clock=new Date()
let hr=clock.getHours()
let min=clock.getMinutes()
let sec=clock.getSeconds()
let hours=document.querySelector("#hours")
if(hr>12)
day.innerHTML="PM"
if(hr>12)
hr=hr-12
if(hr<10)
hr="0"+hr
hours.innerHTML=hr
let minutes=document.querySelector("#minutes")
if(min<10)
min="0"+min
minutes.innerHTML=min
let seconds=document.querySelector("#seconds")
if(sec<10)
sec="0"+sec
seconds.innerHTML=sec
}
setInterval(time,1000)
</script>
</body>
</html>