-
Notifications
You must be signed in to change notification settings - Fork 0
/
work_clock.html
51 lines (34 loc) · 852 Bytes
/
work_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
<style>
#clock {
font-size: 70px;
}
</style>
<div id="clock">
<span class="hour">hh</span>:<span class="min">mm</span>:<span class="sec">ss</span>
</div>
<script>
var timerId;
function update () {
var clock = document.getElementById('clock')
var date = new Date ();
var hours = date.getHours();
if(hours < 10) hours = '0' + hours;
clock.children[0].innerHTML = hours;
var minutes = date.getMinutes();
if(minutes < 10) minutes = '0' + minutes;
clock.children[1].innerHTML = minutes;
var seconds = date.getSeconds();
if(seconds < 10) seconds = '0' + seconds;
clock.children[2].innerHTML = seconds;
}
function startClock() {
update();
timerId = setInterval(update, 1000);
}
startClock();
// function stopClock() {
// clearInterval(timerId)
// timerId = null;
// }
// stopClock();
</script>