时间对比

2020-08-12  本文已影响0人  web小哥MrYang

if(this.time_start(this.formData.promoStartTime)){

                console.log("还没有开始")

                this.changeTaskStatus_i(this.formData.id,-1)

            }else{

                if(this.time_start(this.formData.promoEndTime)){

                    console.log("在活动时间内")//

                    this.changeTaskStatus_i(this.formData.id,0)

                }else{

                    console.log("已结束")//已结束

                    this.changeTaskStatus_i(this.formData.id,1)

                }

            }

//活动时间计算

        time_start(formDatatime){

            var date=new Date(formDatatime.replace(/-/g, '/'));  //开始时间 

            formDatatime=date.getTime();//数据时间

            var formatDateTime=(new Date()).valueOf()//当前时间

            if(formDatatime-formatDateTime >0){

                return true//大于0的话就是传的时间在当前时间之后

            }else{

                return false

            }

        }

上一篇 下一篇

猜你喜欢

热点阅读