-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (17 loc) · 726 Bytes
/
index.js
File metadata and controls
21 lines (17 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const hours = document.getElementById("hours");
const min = document.getElementById("min");
const sec = document.getElementById("sec");
let nowHour = new Date().getHours();
let nowMin = new Date().getMinutes();
let nowSec = new Date().getSeconds();
hours.innerText = (nowHour < 10 ? "0" + nowHour : nowHour);
min.innerText = (nowMin < 10 ? "0" + nowMin : nowMin);
sec.innerText = (nowSec < 10 ? '0' + nowSec : nowSec);
setInterval(() => {
nowHour = new Date().getHours();
nowMin = new Date().getMinutes();
nowSec = new Date().getSeconds();
hours.innerText = nowHour < 10 ? "0" + nowHour : nowHour;
min.innerText = nowMin < 10 ? "0" + nowMin : nowMin;
sec.innerText = nowSec < 10 ? "0" + nowSec : nowSec;
}, 1000);