function excelNumToDate(days) {
if (/^\d+$/.test(days)) {
var startDate = new Date(Date.UTC(1899, 11, 30));
return new Date(startDate.getTime() + (days) * 24 * 3600 * 1000);
} return days;
}
function excelDateToJSDate(days) {
if (/^\d+$/.test(days)) {
return new Date(Math.round((days - 25569) * 86400 * 1000));
// return new Date((days - (25567 + 2)) * 86400 * 1000);
} return days;
}
function parseExcelDate(excelSerialDate) {
if (/^\d+$/.test(days)) {
var daysBeforeUnixEpoch = 70 * 365 + 19;
var hour = 60 * 60 * 1000;
return new Date(Math.round((excelSerialDate - daysBeforeUnixEpoch) * 24 * hour) + 12 * hour);
} return days;
}
JS 将 Excel 中序列化日期 26942 转换为 Date 对象
于 2024-05-29 21:16:04 首次发布