时间格式转化 (DatePicker可以使用)

dateFormat (date) {
            // console.log(new Date(date).getFullYear())
            let time = new Date(date);
            let year = time.getFullYear();
            let month = Number(Number(time.getMonth()) + 1) >= 10 ? Number(time.getMonth()) + 1 : '0' + Number(Number(time.getMonth()) + 1);
            let day = Number(time.getDate()) >= 10 ? time.getDate() : '0' + time.getDate();
            let hour = Number(time.getHours()) >= 10 ? time.getHours() : '0' + time.getHours();
            let minutes = Number(time.getMinutes()) >= 10 ? time.getMinutes() : '0' + time.getMinutes();
            let second = Number(time.getSeconds()) >= 10 ? time.getSeconds() : '0' + time.getSeconds();
            return `${year}-${month}-${day} ${hour}:${minutes}:${second}`;
        },

你可能感兴趣的:(时间格式转化 (DatePicker可以使用))