有時(shí)候我們通過(guò)XLSX讀取日期單元格時(shí),會(huì)出現(xiàn)一串由數(shù)字表示的時(shí)間,處理起來(lái)不是很方便。
這里我們使用moment來(lái)解決這個(gè)問(wèn)題
const moment = require('moment');
const changeDate = (timeNum) => {
const d = timeNum - 1;
const t = Math.round((d - Math.floor(d)) * 24 * 60 * 60);
return moment(new Date(1900, 0, d, 0, 0, t)).format('YYYY-MM-DD HH:mm:ss');
}