여기서는 '분'만 실시간으로 업데이트되게 구현하였다.
<div class="clock">
<span class="time"></span>
<span class="name"></span>
</div>
function setClock() {
const today = new Date();
const hour = today.getHours();
const minutes = today.getMinutes();
const todayTime = `${hour}:${minutes}`;
showClock(todayTime);
setTimeout(setClock, 1000);
}
function showClock(time) {
const spanClock = document.querySelector(".time");
spanClock.innerHTML = time;
}
setClock();