
js코드
const h1=document.querySelector('h1')
function init()
{
setInterval(currentClock ,1000)
}
init();
function currentClock(){
const allClock=new Date();
const hour=allClock.getHours();
const minute=allClock.getMinutes();
const second=allClock.getSeconds();
const day=allClock.getMonth()
h1.innerHTML=`${hour}시 ${minute}분 ${second<10 ?`0${second}초`: `${second}초`}, 지금은 ${day}월`
console.log(day)
}드를 입력하세요
html 코드
<h1> 00:00</h1>