-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (32 loc) · 1.05 KB
/
index.js
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
setInterval(() => {
d=new Date();
hourtime = d.getHours();
minutetime = d.getMinutes();
secondtime = d.getSeconds();
if (hourtime > 12)
{
ampm = "PM"
}
else{
ampm = "AM"
}
hour12format = hourtime % 12;
if (hour12format.toString().length == 1) {
hour12format = "0" + hour12format;
}
if (hourtime.toString().length == 1) {
hourtime = "0" + hourtime;
}
if (secondtime.toString().length == 1) {
secondtime = "0" + secondtime;
}
digitalTime = hour12format+" : "+minutetime+" : "+secondtime+" "+ampm ;
console.log(digitalTime);
hrotation = 30* hourtime + minutetime/2;
mrotation = minutetime * 6;
srotation = secondtime * 6;
hourhand.style.transform = `rotate(${hrotation}deg)`;
secondhand.style.transform = `rotate(${srotation}deg)`;
minutehand.style.transform = `rotate(${mrotation}deg)`;
document.getElementById("digitalClock").innerHTML = `<div>${digitalTime}</div>`;
}, 1000);