날짜 시간 대비

1999 단어 자바 script
/ / 현재 시간 과 점포 의 영업시간 비교
//             
  getJudgeBusinessLDY: function () {
    // *********** begin**************
    //      
    //         
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;
    //        
    var n = timestamp * 1000;
    var date = new Date(n);
    var Yeart = date.getFullYear(); //   
    var Mon = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);//   
    var Dates = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();//   
    var hours = date.getHours();//   
    var mint = date.getMinutes();//   
    var sec = date.getSeconds();// 
    if (mint < 10) {
      mint = "0" + mint;
    } else {
      mint = mint;
    }
    if (sec < 10) {
      sec = "0" + sec;
    } else {
      sec = sec;
    }
    var runTime = this.data.store.run_timeStr;
    var nowTime = Yeart + '-' + Mon + '-' + Dates + ' ' + hours + ":" + mint + ":" + sec;//    
    var beginRunTime = Yeart + '-' + Mon + '-' + Dates + ' ' + runTime.substring(0, 8);//      
    var endRunTime = Yeart + '-' + Mon + '-' + Dates + ' ' + runTime.substring(9, 17);//      
    console.log(nowTime)
    console.log(beginRunTime + "----" + endRunTime)
    var nowTimes = nowTime.replace(/-/g, "/");
    var beginTimes = beginRunTime.replace(/-/g, "/");
    var endTimes = endRunTime.replace(/-/g, "/");
    var beginNum = (Date.parse(nowTimes) - Date.parse(beginTimes)) / 3600 / 1000;//             
    var endNum = (Date.parse(nowTimes) - Date.parse(endRunTime)) / 3600 / 1000;//             
    console.log("beginNum:" + beginNum + " endNum:" + endNum)
    if (beginNum >= 0 && endNum <= 0) {
      //     
      return true;
    } else {
      //      
      return false;
    }
    // *********** end****************
  },

좋은 웹페이지 즐겨찾기