美文网首页
vue中excel遇见时间处理

vue中excel遇见时间处理

作者: world_7735 | 来源:发表于2020-10-09 10:15 被阅读0次

//时间44073 ---- 实际时间:2020-8-30


exportDate(numb) {

        function formatTime(date) {

            return year + '-' + month + '-' + day;

        }

        if (numb > 0) { //  先解析时间

            const time = new Date((numb - 1) * 24 * 3600000 + 1);

            let h = time.getHours() + 16;

            let yeraData = new Date(1900, 0, numb - 1)

            let year = yeraData.getFullYear();

            let month = yeraData.getMonth() + 1

            month = month < 10 ? '0' + month : month;

            let day = yeraData.getDate()

            day = day < 10 ? '0' + day : day;

            if (h > 23) {

                h = h - 24;

            }

            let m = time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes();

            let s = time.getSeconds() < 10 ? "0" + time.getSeconds() : time.getSeconds();

            return `${year}-${month}-${day} ${h}:${m}:${s}`;

        } else {

            // console.log(numb)

            return '非法日期格式';

        }

    },



相关文章

网友评论

      本文标题:vue中excel遇见时间处理

      本文链接:https://www.haomeiwen.com/subject/nptlpktx.html