-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (26 loc) · 881 Bytes
/
script.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
function updateTime() {
let a = new Date()
let hours = a.getHours()
let minutes = a.getMinutes()
let day = a.getDay()
let date = a.getDate()
let mont = a.getMonth()
let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][day]
let month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12][mont]
let h = document.getElementById("hours");
let m = document.getElementById("minutes");
let format = document.getElementById("format")
let Day = document.getElementById("day");
let dat = document.getElementById("date");
let mon = document.getElementById("month");
let period = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12; // If hours is 0, set it to 12 for 12 AM
h.innerHTML = hours;
m.innerHTML = minutes;
Day.innerHTML = days;
format.innerHTML = period;
mon.innerHTML = month;
dat.innerHTML = date;
}
updateTime();
setInterval(updateTime, 1000);