-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigital-clock.html
More file actions
36 lines (34 loc) · 908 Bytes
/
Copy pathdigital-clock.html
File metadata and controls
36 lines (34 loc) · 908 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Digital Clock</title>
<link rel="stylesheet" href="css/clock.css">
</head>
<body>
<div>
<div id ="clock">
<h2> The time is now</h2>
<div id="time">
<div><span id="hour">00</span><span>Hours</span></div>
<div><span id="minutes">00</span><span>Minutes</span></div>
<div><span id="seconds">00</span><span>Seconds</span></div>
</div>
</div>
</div>
<script type ='text/javascript'>
function clock() {
let hours = document.getElementById('hour');
let minutes = document.getElementById('minutes');
let seconds = document.getElementById('seconds');
let h = new Date().getHours();
let m = new Date().getMinutes();
let s = new Date().getSeconds();
hours.innerHTML = h;
minutes.innerHTML = m;
seconds.innerHTML = s;
}
let interval = setInterval(clock, 1000);
</script>
</body>
</html>