-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (20 loc) · 1.02 KB
/
index.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
29
30
31
32
// Add this JavaScript to index.js
function updateClock() {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours() % 12; // Ensure 12-hour format
const secHand = document.getElementById('secHand');
const minHand = document.getElementById('minHand');
const hrHand = document.getElementById('hrHand');
const secDeg = (seconds / 60) * 360;
const minDeg = (minutes / 60) * 360 + (seconds / 60) * 6;
const hrDeg = (hours / 12) * 360 + (minutes / 60) * 30;
secHand.style.transform = `translateX(-50%) rotate(${secDeg}deg)`;
minHand.style.transform = `translateX(-50%) rotate(${minDeg}deg)`;
hrHand.style.transform = `translateX(-50%) rotate(${hrDeg}deg)`;
const CurrentDate11 = document.getElementById('date');
CurrentDate11.innerHTML = now.getFullYear();
}
setInterval(updateClock, 1000); // Update the clock every second
updateClock(); // Initial update