es6获取时分秒

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

你可能感兴趣的:(es6获取时分秒)