SOURCE

/**
 * @desc 每隔一秒打印时间
 */
(
   function get() {
        setInterval(()=>{
          getTime()
        },1000)

    function getTime() {
      const date = new Date()
        const year = date.getFullYear()
        const month = (date.getMonth()+1).toString().padStart(2,'0') 
        const day = (date.getDay()).toString().padStart(2,'0') 
        const hour = date.getHours().toString().padStart(2,'0') 
        const minute = date.getMinutes().toString().padStart(2,'0') 
        const seconds = date.getSeconds().toString().padStart(2,'0') 

        return console.log(`${year}年-${month}月-${day}日 ${hour}:${minute}:${seconds}`)
    }
    }
)()
// 2021年-12月-04日 11:23:16
console 命令行工具 X clear

                    
>
console