-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (21 loc) · 1.01 KB
/
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
function updateTime() {
let now = new Date();
let hours = now.getHours();
let minutes = now.getMinutes();
let seconds = now.getSeconds();
let ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12;
document.getElementById('hours').innerText = hours.toString().padStart(2, '0');
document.getElementById('minutes').innerText = minutes.toString().padStart(2, '0');
document.getElementById('seconds').innerText = seconds.toString().padStart(2, '0');
document.getElementById('am-pm').innerText = ampm;
let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
let day = days[now.getDay()];
let dates = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
let date = dates[now.getMonth()];
date += ' ' + now.getDate();
document.getElementById('date').innerText = date;
document.getElementById('day').innerText = day;
}
setInterval(updateTime, 1000);
updateTime();