-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (18 loc) · 709 Bytes
/
script.js
File metadata and controls
26 lines (18 loc) · 709 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
25
26
const deg = 6;
const clock = document.querySelector(".clock");
const hr = clock.children[0];
const mn = clock.children[1];
const sc = clock.children[2];
const dt = document.querySelector(".dt");
function updateTimer() {
const currentDate = new Date();
const hh = currentDate.getHours() * 30;
const mm = currentDate.getMinutes() * deg;
const ss = currentDate.getSeconds() * deg;
hr.style.transform = `rotateZ(${hh + (mm/12)}deg)`;
mn.style.transform = `rotateZ(${mm}deg)`;
sc.style.transform = `rotateZ(${ss}deg)`;
dt.innerHTML = currentDate.toLocaleDateString('default', {month: "numeric", day: "numeric"})
}
setInterval(() => updateTimer(), 1000);
updateTimer()