-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (16 loc) · 701 Bytes
/
script.js
File metadata and controls
24 lines (16 loc) · 701 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
function setClockHands() {
let now = new Date();
let seconds = now.getSeconds();
let minutes = now.getMinutes();
let hours = now.getHours();
let secondHand = document.querySelector(".sec-hand");
let minuteHand = document.querySelector(".min-hand");
let hourHand = document.querySelector(".hr-hand");
let secondsDegrees = 6*seconds;
let minutesDegrees = 6*minutes;
let hoursDegrees = 30*hours + minutes/2;
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
}
setInterval(setClockHands, 1000);