-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
17 lines (15 loc) · 888 Bytes
/
Copy pathscript.js
File metadata and controls
17 lines (15 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var second = 0;
var minute = 0;
var hour = 0;
var d = new Date();
setInterval(
function() {
d = new Date(); // d is a variable that gets the date automatically
second = d.getSeconds() * 6; //this is so that the "seconds-hand" can move 6 times
minute = d.getMinutes() * 6; //the same thing is applied here
hour = d.getHours() * 30 + Math.round(minute / 12); //we have 12 hours it has to be divided by 12 i.e 360(deg)/12 gives 30
document.getElementById("second-hand").style.transform = "rotate(" + second + "deg)"; //to enable the "seconds hand" to move
document.getElementById("minute-hand").style.transform = "rotate(" + minute + "deg)"; //to enable the "minutes hand" to move
document.getElementById("hour-hand").style.transform = "rotate(" + hour + "deg)"; //to enable the "hour hand" to move
},1000
)