// 时间戳转时间functiontimestampToTime(timestamp){// 不足2位需补0constformatNumber=(num)=>String(num).length <2?'0'+ num : num
const date =newDate(timestamp)// 年月日constY= date.getFullYear()// 月份从0开始需+1constM=formatNumber(date.getMonth()+1)constD=formatNumber(date.getDate())// 时分秒const h =formatNumber(date.getHours())const m =formatNumber(date.getMinutes())const s =formatNumber(date.getSeconds())// 拼接constYMD=[Y,M,D].join('-')const hms =[h, m, s].join(':')const time =[YMD, hms].join(' ')return time
}
console.log(timestampToTime(1700796594445))