vue el 自動計算時間加1天


/** 計算結束時間方法**/
            effectiveEndTimeHander(value){
                const year1 = 8*365;
                //注冊日期+延保產品服務年限8
                this.formOrder.effectiveEndTime=this.formCar.regDate;

                let tomorrow = new Date(value);
                let nowDate = this.getNowFormatDate();
                tomorrow.setTime(tomorrow.getTime() + 24 * 60 * 60 * 1000);
                let reduce = '-';
                let year = tomorrow.getFullYear() + reduce + this.addZero(tomorrow.getMonth() + 1) + reduce + this.addZero(tomorrow.getDate());

                let t_timestamp = Math.round(new Date(year) / 1000);
                let n_timestamp = Math.round(new Date(nowDate) / 1000);

                if(t_timestamp > n_timestamp){
                    return this.msgError('不能超過今天');
                }else{
                    this.formOrder.effectiveEndTime = year;
                }
            },
            getNowFormatDate: function () {
                let date = new Date();
                let reduce = "-";
                let currentdate = date.getFullYear() + reduce + this.addZero(date.getMonth() + 1) + reduce + this.addZero(date.getDate());
                return currentdate;
            },
            addZero: function (time) {
                if (time >= 1 && time <= 9) {
                    time = "0" + time;
                }
                return time;
            },

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM