-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
27 lines (22 loc) · 817 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
function setClock() {
let date = new Date();
let hour = date.getHours();
let minute = date.getMinutes();
let seconds = date.getSeconds();
document.getElementById("hour").textContent = hour;
document.getElementById("minute").textContent = minute;
document.getElementById("seconds").textContent = seconds;
if(seconds < 10){
document.getElementById("seconds").textContent = 0;
document.getElementById("seconds").textContent += seconds;
}
if(minute < 10){
document.getElementById("minute").textContent = 0;
document.getElementById("minute").textContent += minute;
}
if(hour < 10){
document.getElementById("hour").textContent = 0;
document.getElementById("hour").textContent += hour;
}
}
setInterval(setClock, 1000);