js 取到excel的时间格式是44147,如何转成时间格式

44147是excel中时间格式的整形,如果读取文件拿到这个值,需要进行时间进行转化

formatDate(numb, format) {
            const time = new Date((numb - 1) * 24 * 3600000 + 1)
            time.setYear(time.getFullYear() - 70)
            const year = time.getFullYear() + ''
            const month = time.getMonth() + 1 + ''
            const date = time.getDate() - 1 + ''
            if (format && format.length === 1) {
                return year + format + month + format + date
            }
            return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
},

 this.formatDate(arr,'-')

 


版权声明:本文为fly_vip原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。