【vue】vue中时间格式化YYYYMMDD

    科技2025-03-31  11

    封装

    formatLongDate (date) { let myyear = date.getFullYear(); let mymonth = date.getMonth() + 1; let myweekday = date.getDate(); let myHour = date.getHours(); let myMin = date.getMinutes(); let mySec = date.getSeconds(); if (mymonth < 10) { mymonth = '0' + mymonth; } if (myweekday < 10) { myweekday = '0' + myweekday; } if (myHour < 10) { myHour = '0' + myHour; } if (myMin < 10) { myMin = '0' + myMin; } if (mySec < 10) { mySec = '0' + mySec; } return (myyear + '' + mymonth + '' + myweekday + '' + myHour + '' + myMin + '' + mySec); },

    调用

    let date_value2 = this.formatLongDate(this.form.endTime); console.log(date_value);
    Processed: 0.014, SQL: 8