// 把excel文件中的日期格式的内容转回成标准时间
// https://blog.youkuaiyun.com/qq_15054679/article/details/107712966
export function formatExcelDate(numb, format = '/') {
const time = new Date((numb - 25567) * 24 * 3600000 - 5 * 60 * 1000 - 43 * 1000 - 24 * 3600000 - 8 * 3600000)
time.setYear(time.getFullYear())
const year = time.getFullYear() + ''
const month = time.getMonth() + 1 + ''
const date = time.getDate() + ''
if (format && format.length === 1) {
return year + format + month + format + date
}
return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
}
可以把excel格式日期 如 45621 转换为 20xx/xx/xx 这种格式
该博客介绍了一个JavaScript函数,用于将Excel格式的日期(如45621)转换为标准的日期字符串(20xx/xx/xx)。通过将Excel日期数值乘以相应的时间常数并进行调整,然后使用Date对象处理,最终得到所需的日期格式。
815

被折叠的 条评论
为什么被折叠?



