javascript program for analog clock

Solutions on MaxInterview for javascript program for analog clock by the best coders in the world

showing results for - "javascript program for analog clock"
Loris
14 May 2019
1 const hourHand = document.querySelector('.hand-hour');
2    const minuteHand = document.querySelector('.hand-minute');
3    const secondHand = document.querySelector('.hand-seconds');
4
5
6    function getTime() {
7        const now = new Date();
8
9        const seconds = now.getSeconds();
10        const secondsDegree = (((seconds / 60) * 360) + 90);
11        secondHand.style.transform = `rotate(${secondsDegree}deg)`
12
13
14        const minutes = now.getMinutes();
15        const minutesDegree = (((minutes / 60) * 360) + 90);
16        minuteHand.style.transform = `rotate(${minutesDegree}deg)`
17
18
19        const hours = now.getHours();
20        const hoursDegree = (((hours / 60) * 360) + 90);
21        hourHand.style.transform = `rotate(${hoursDegree}deg)`
22
23
24
25    }
26
27    setInterval(getTime, 1000);
28