封装

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);
Logo

前往低代码交流专区

更多推荐