废话不多说,直接上代码:
formatDate (timeNum) {
const time = new Date(((Number(timeNum) - 70 * 365 - 19) * 24 * 3600 - 8 * 3600 - 42.5) * 1000)
const year = time.getFullYear()
const month = time.getMonth() + 1
const date = time.getDate()
const hour = time.getHours()
const min = time.getMinutes()
const sec = time.getSeconds()
const dateArr = [
year,
(month < 10 ? '0' + month : month),
(date < 10 ? '0' + date : date),
]
const timeArr = [
(hour < 10 ? '0' + hour : hour),
(min < 10 ? '0' + min : min),
(sec < 10 ? '0' + sec : sec),
]
return `${dateArr.join('-')} ${timeArr.join(':')}`
}
标签:10,const,min,excel,js,导入,time,date,month From: https://www.cnblogs.com/foreveronlymiss/p/17069937.html
亲测有效哈~