【vue】vue中时间格式化YYYYMMDD

  • Post author:
  • Post category:vue


封装

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



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