js设置时间组件

 

var date = new Date(), y = date.getFullYear(), m = date.getMonth(),d = date.getDate();
        var monthFirstDay = new Date(y, m-1, d);
        var timeArr = [monthFirstDay, new Date()];
        this.searchData.queryTimeArr = timeArr;

 js天数差 日期差

//判断日期差
    dateDiff(sDate1, sDate2) {
      var  aDate,  oDate1,  oDate2,  iDays
      aDate = sDate1.substring(0, 10).split("-")  
      oDate1 = new Date(aDate[0] , aDate[1] ,aDate[2])
      aDate = sDate2.substring(0, 10).split("-")  
      oDate2 = new Date(aDate[0] , aDate[1] , aDate[2])  
      iDays = parseInt(Math.abs(oDate1  -  oDate2)  /  1000  /  60  /  60  /24)  //把相差的毫秒数转换为天数  
      return iDays
    },

// ----------下面是调用----------
this.dateDiff(this.searchData.queryStartTime, this.searchData.queryEndTime) > 31

 

posted @ 2023-08-29 14:55  君子笑而不语  阅读(71)  评论(0编辑  收藏  举报