-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclock.js
More file actions
45 lines (40 loc) · 1.16 KB
/
clock.js
File metadata and controls
45 lines (40 loc) · 1.16 KB
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
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');
hr_dot = document.querySelector('.hr_dot');
mn_dot = document.querySelector('.mn_dot');
sc_dot = document.querySelector('.sc_dot');
document.getElementById('hours').innerHTML=hours /*+ '<br><span>hours</span></br>';*/
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;
hr_dot.style.transform = `rotate(${hours * 30}deg)`;
mn_dot.style.transform = `rotate(${minute * 6}deg)`;
sc_dot.style.transform = `rotate(${second * 6}deg)`;
}, 1000);