日期时间对比
//現(xiàn)在時(shí)間和店鋪的營(yíng)業(yè)時(shí)間相對(duì)比
// 判斷店鋪是否處于營(yíng)業(yè)時(shí)間getJudgeBusinessLDY: function () {// *********** begin**************// 現(xiàn)在時(shí)間//獲取當(dāng)前時(shí)間戳 var timestamp = Date.parse(new Date());timestamp = timestamp / 1000;//獲取當(dāng)前時(shí)間 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();//時(shí) 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;//現(xiàn)在時(shí)間var beginRunTime = Yeart + '-' + Mon + '-' + Dates + ' ' + runTime.substring(0, 8);//開(kāi)始營(yíng)業(yè)時(shí)間var endRunTime = Yeart + '-' + Mon + '-' + Dates + ' ' + runTime.substring(9, 17);//結(jié)束營(yíng)業(yè)時(shí)間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;//現(xiàn)在時(shí)間與開(kāi)始營(yíng)業(yè)時(shí)間相比var endNum = (Date.parse(nowTimes) - Date.parse(endRunTime)) / 3600 / 1000;//現(xiàn)在時(shí)間與結(jié)束營(yíng)業(yè)時(shí)間相比console.log("beginNum:" + beginNum + " endNum:" + endNum)if (beginNum >= 0 && endNum <= 0) {// 營(yíng)業(yè)時(shí)間return true;} else {// 非營(yíng)業(yè)時(shí)間return false;}// *********** end****************},
總結(jié)
- 上一篇: 《论文阅读》Commonsense Kn
- 下一篇: 《你的灯还亮着吗》读书笔记