-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.js
62 lines (53 loc) · 1.47 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var div = document.getElementById('DSEGClock');
var date = document.getElementById('date');
var day = document.getElementById('din');
var seconds = document.getElementById('seconds');
var session = document.getElementById('sessin');
var dat = document.getElementById('date');
function time() {
div.innerHTML = "";
var d = new Date();
var s = d.getSeconds();
var m = d.getMinutes();
var h = d.getHours();
var sesn = "AM";
if (h > 12) {
h = h - 12;
}
if (h < 10) {
h = "0" + h;
}
if (m < 10) {
m = "0" + m;
}
if (h == 0) {
h = 12;
}
if (h => 12) {
sesn = "PM";
}
if (s < 10) {
s = "0" + s;
}
var mnth = d.getMonth()+1;
var date = d.getDate();
var year = d.getFullYear();
var daylist = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
var fa_day = d.getDay();
fa_day = daylist[fa_day];
if (mnth==0) {
mnth=12;
}
if (date < 10) {
date = "0" + date;
}
if (mnth < 10) {
mnth = "0" + mnth;
}
div.innerHTML = h + ":" + m;
day.innerHTML = fa_day;
seconds.innerHTML = s;
session.innerHTML = sesn;
dat.innerHTML = date + "-" + mnth + "-" + year;
}
setInterval(time, 1000);