-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (19 loc) · 763 Bytes
/
Copy pathapp.js
File metadata and controls
23 lines (19 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const secondsHand = document.getElementById("seconds-hand");
const minutesHand = document.getElementById("minutes-hand");
const hoursHand = document.getElementById("hours-hand");
function getTime() {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
const timeInterval = 6;
secondsHand.style.transform = "rotate(" + seconds * timeInterval + "deg)";
minutesHand.style.transform =
"rotate(" + (minutes * timeInterval + seconds / 10) + "deg)";
hoursHand.style.transform = "rotate(" + (hours * 30 + minutes / 2) + "deg)";
}
setInterval(getTime, 100);
getTime();
secondsHand.style.display = "block";
minutesHand.style.display = "block";
hoursHand.style.display = "block";