forked from Tomkndn/gitproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.js
More file actions
37 lines (34 loc) · 858 Bytes
/
clock.js
File metadata and controls
37 lines (34 loc) · 858 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
37
let a;
setInterval(() => {
a = new Date();
hours = a.getHours();
minute = a.getMinutes();
second = a.getSeconds();
am = a.getHours();
if (hours > 12) {
hours -= 12;
} else if (hours == 0) {
hours = 12;
}
if (hours < 10){
hours = "0" + hours;
}
if (minute < 10 ){
minute = "0" + minute;
}
if (second < 10 ){
second = "0" + second;
}
if (am > 12){
document.getElementById('ampm').innerHTML='PM';
}
hh = document.getElementById('hh');
mm = document.getElementById('mm');
ss = document.getElementById('ss');
document.getElementById('hours').innerHTML=hours;
document.getElementById('minute').innerHTML=minute;
document.getElementById('second').innerHTML=second;
hh.style.strokeDashoffset = 440 - (440 * hours) / 12;
mm.style.strokeDashoffset = 440 - (440 * minute) / 60;
ss.style.strokeDashoffset = 440 - (440 * second) / 60;
}, 1000);