setInterval(()=>{
constnow =newDate()
const? hours = now.getHours().toString()
const minutes = now.getMinutes().toString()
const seconds = now.getSeconds().toString()
console.log(`${hours.padStart(2,0)}:${minutes.padStart(2,0)}:${seconds.padStart(2,0)}`) },1000)
打印出:? ? ?20:28:51