-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (22 loc) · 896 Bytes
/
app.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
const secondHand = document.querySelector(".second-hand");
const minuteHand = document.querySelector(".min-hand");
const hourHand = document.querySelector(".hour-hand");
function setDate() {
// console.log('hi');
const now = new Date();
const seconds = now.getSeconds();
const secondsToDegrees = ((seconds / 60) * 360) + 90;
secondHand.style.transform = `rotate(${secondsToDegrees}deg)`;
const minutes = now.getMinutes();
const minutesToDegrees = ((minutes / 60) * 360) + 90;
minuteHand.style.transform = `rotate(${minutesToDegrees}deg)`;
let hours = now.getHours();
if(hours>12){
var hoursToDegrees = (((hours -12) / 12) * 360) + ((minutes/60)*30) + 90;
}
else{
var hoursToDegrees = ((hours / 12) * 360) + ((minutes/60)*30) + 90;
}
hourHand.style.transform = `rotate(${hoursToDegrees}deg)`;
}
setInterval(setDate, 1000);