示例图
代码
function getTime(id) {
setInterval(() => {
let keep = ''
let date = new Date()
let y = date.getFullYear()
let m = (date.getMonth() + 1).toString().padStart(2, '0')
let d = date.getDate().toString().padStart(2, '0')
let h = date.getHours().toString().padStart(2, '0')
let f = date.getMinutes().toString().padStart(2, '0')
let s = date.getSeconds().toString().padStart(2, '0')
keep = y + '年' + m + '月' + d + '日 ' + h + ':' + f + ':' + s
$("#" + id).text(keep)
}, 1000)
}