-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
60 lines (49 loc) · 1.72 KB
/
Copy pathindex.html
File metadata and controls
60 lines (49 loc) · 1.72 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS + CSS Clock</title>
<link rel="icon" href="https://fav.farm/🕒" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="clock">
<div class="clock-face">
<div class="middleCircle "></div>
<div class="hand hour-hand"></div>
<div class="hand min-hand"></div>
<div class="hand second-hand"></div>
<div class="digitalTime">
<p id="hour">00</p>
<span>:</span>
<p id="min">00</p>
</div>
</div>
<p id="second">00</p>
</div>
<script>
const secondHand = document.querySelector('.second-hand')
const minHand = document.querySelector('.min-hand')
const hourHand = document.querySelector('.hour-hand')
const second = document.getElementById('second')
const min = document.getElementById('min')
const hour = document.getElementById('hour')
function setDate(){
const now = new Date();
// Set the hours hand rotation based on current time
const secondsDegrees = ((now.getSeconds() / 60) * 360) + 90;
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
second.innerHTML = now.getSeconds();
//Set minutes Hand Rotation Based On Current Time
const minuteDegrees = ((now.getMinutes() / 60 ) * 360) + 90;
minHand.style.transform = `rotate(${minuteDegrees}deg)`;
min.innerHTML = now.getMinutes();
//Set hour Hand Rotation Based On Current Time
const hourDegrees = ((now.getHours() / 60 ) * 360) + 90;
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
hour.innerHTML = now.getHours();
}
setInterval(setDate,1000)
</script>
</body>
</html>