-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclock.js
More file actions
26 lines (19 loc) · 945 Bytes
/
clock.js
File metadata and controls
26 lines (19 loc) · 945 Bytes
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
const hourHand = document.querySelector('#hours');
const minuteHand = document.querySelector('#minutes');
const secondHand = document.querySelector('#seconds');
const dayOfWeek = document.querySelector('#day');
const month = document.querySelector('#month');
const dateNumber = document.querySelector('#date');
function updateClock() {
const now = new Date();
hourHand.textContent = now.getHours();
minuteHand.textContent = now.getMinutes();
secondHand.textContent = now.getSeconds();
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
dayOfWeek.textContent = days[now.getDay()];
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
month.textContent = months[now.getMonth()];
dateNumber.textContent = now.getDate();
}
setInterval(updateClock, 1000);
updateClock();