-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.js
46 lines (40 loc) · 1.42 KB
/
clock.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
setInterval(() => {
d = new Date();
htime = d.getHours();
mtime = d.getMinutes();
stime = d.getSeconds();
hrotation = 30*htime + mtime/2;
mrotation = 6*mtime;
srotation = 6*stime;
hour.style.transform = `rotate(${hrotation}deg)`;
minute.style.transform = `rotate(${mrotation}deg)`;
second.style.transform = `rotate(${srotation}deg)`;
}, 1000);
function updateClock(){
var now = new Date();
var dname =now.getDay()
mo = now.getMonth(),
dnum= now.getDate(),
yr = now.getFullYear(),
hou = now.getHours(),
min2 = now.getMinutes(),
sec2 = now.getSeconds(),
pe ="AM";
if(hou == 0){
hou = 12;
}
if(hou >12){
hou = hou -12;
pe = "PM";
}
var months = ["January","February","March","April","May","June","July","Augest","September","October","November","December"];
var week = ["Sunday","Monday","Tuesday","Wednessday","Thusday","Friday","satuarday"];
var ids = ["dayname","month","daynum","year","hour2","minute2","second2","period"];
var values = [week[dname],months[mo],dnum,yr,hou,min2,sec2,pe];
for(var i =0; i <ids.length; i++)
document.getElementById(ids[i]).firstChild.nodeValue = values[i];
}
function initClock(){
updateClock();
window.setInterval("updateClock()",1);
}