-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2.js
27 lines (19 loc) · 883 Bytes
/
2.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
function start() {
const secondHand = document.querySelector(".second-hand");
const minuteHand = document.querySelector(".min-hand");
const hourHand = document.querySelector(".hour-hand");
function setDate() {
const now = new Date();
const seconds = now.getSeconds();
const secondDegrees = seconds * 6 + 90;
secondHand.style.transform = `rotate(${secondDegrees}deg)`;
const minutes = now.getMinutes();
const minuteDegrees = (minutes / 60) * 360 + (seconds / 60) * 6 + 90;
minuteHand.style.transform = `rotate(${minuteDegrees}deg)`;
const hours = now.getHours();
const hourDegrees = (hours / 12) * 360 + (minutes / 60) * 30 + 90;
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
}
setInterval(setDate, 1000);
}
document.addEventListener("DOMContentLoaded", start);