-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.js
More file actions
22 lines (17 loc) · 733 Bytes
/
clock.js
File metadata and controls
22 lines (17 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const handSecond = document.querySelector('.second-hand');
const handMinute = document.querySelector('.min-hand');
const handHour = document.querySelector('.hour-hand');
function setDate() {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
const DegreeSec = ((seconds / 60) * 360) + 90;
const DegreeMin = ((minutes / 60) * 360) + 90;
const DegreeHour = ((hours / 24) * 360) + 90;
handSecond.style.transform = `rotate(${DegreeSec}deg)`;
handMinute.style.transform = `rotate(${DegreeMin}deg)`;
handHour.style.transform = `rotate(${DegreeHour}deg)`;
//console.log(seconds);
}
setInterval(setDate, 1000);