微信小程式時間邏輯判斷

2021-10-07 21:24:21 字數 1403 閱讀 5305

最近專案上有個需求,計算請假時間,時間有效範圍是09:00:00到17:00:00;最好是去掉週末,很遺憾我這裡沒有排除掉,新人一枚,把自己做的發出來供大家指正一下,如果有更好的辦法歡迎交流討論;

counttime:function()else if(!that.comparedate(startdate,date1+' 09:00:00'))else

let time2

if(!that.comparedate(date2+' 17:00:00',enddate))else if(that.comparedate(date2+' 17:00:00',enddate) && !that.comparedate(date2+' 09:00:00',enddate))else

if(time1==0||time2==0)

const start_date = new date(time1)

const end_date = new date(time2)

let time = (end_date.gettime() - start_date.gettime())/(1000*60*60)

console.log(time)

hours = time.tofixed(2)

}elseelse if(!that.comparedate(date2+' 09:00:00',enddate) && !that.comparedate(enddate,date2+' 17:00:00'))else if(that.comparedate(enddate,date2+' 17:00:00'))

}else if(!that.comparedate(date1+' 09:00:00',startdate) && !that.comparedate(startdate,date1+' 17:00:00'))else if(!that.comparedate(date2+' 09:00:00',enddate) && !that.comparedate(enddate,date2+' 17:00:00'))else if(enddate,date2+' 17:00:00')

}else if(that.comparedate(startdate,date1+' 17:00:00'))else if(!that.comparedate(date2+' 09:00:00',enddate) && !that.comparedate(enddate,date2+' 17:00:00'))else if(that.comparedate(enddate,date2+' 17:00:00'))}}

return hours

},//日期大小比較

comparedate(date1,date2) else

},

loadweek:function(),
待完善

微信小程式時間繫結分析

view searchinput searchinput tabs tabs bindstabsitemchange handletabsitemchange block wx if 0 block block wx elif 1 block block wx elif 2 block tabs v...

微信小程式時間加法 微信小程式日期轉換 比較 加減

日期轉時間戳 functiongetunixtime datestr 時間戳轉日期,falg true表示只要年月日,part year month date functiontodate number,flag,part else if part month else if part date r...

微信小程式 時間戳轉日期

util.js 時間戳轉換成日期時間 function js date time unixtime module.exports 使用方法 變數時間戳轉換成日期 例 arr是字串 index.js var util require utils util.js var arr 153596077300...