js读取excel中日期格式转换问题
// tslint:disable-next-line:typedef
formatDate2(numb: any, format: any, mao: any) {
const time: any = new Date((numb - 1) * 24 * 3600000 + 1);
time.setYear(time.getFullYear() - 70);
const year: any = time.getFullYear() + '';
const month: any = time.getMonth() + 1 + '';
const date: any = time.getDate() - 1 + '';
const houer: any = time.getHours() - 8 + '';
const minutes: any = time.getMinutes() + '';
const seconds: any = time.getSeconds() + '';
if (format && format.length === 1) {
// tslint:disable-next-line:max-line-length
return year + format + month + format + date + ' ' + (houer < 10 ? (houer === 0 ? '00' : '0' + houer ) : houer) + mao + (minutes < 10 ? (minutes === 0 ? '00' : '0' + minutes ) : minutes) + mao + (seconds < 10 ? (seconds === 0 ? '00' : '0' + seconds ) : seconds);
}
return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date) + ' ' + (houer < 10 ? '0' + date : date);
}
console.log(this.datePipe.transform(this.formatDate2(this.inputdata[1][1], '-', ':'), 'yyyy-MM-dd HH:mm:ss'))
// 结果 2021-08-12 08:12:00