12 lines
422 B
JavaScript
12 lines
422 B
JavaScript
|
|
function updateClock(){
|
|
const time = new Date();
|
|
const hours = time.getHours().toString().padStart(2, "0");
|
|
const minutes = time.getMinutes().toString().padStart(2, "0");
|
|
const seconds = time.getSeconds().toString().padStart(2, "0");
|
|
const time_string = `${hours}:${minutes}:${seconds}`;
|
|
document.getElementById("clock").textContent = time_string;
|
|
}
|
|
|
|
updateClock();
|
|
setInterval(updateClock, 1000); |