Examples are as follows:
//Start date, /pattern/ is the delimiter of the regular expression, pattern is the content to be matched, and is only used for the first symbol matching, g is the global matching flag var beginDate = new Date("2013-01-01".replace(/-/g, "/"));//End date var endDate = new Date("2013-01-31".replace(/-/g, "/"));//Date difference, that is, the working hours in Saturday, day, and working hours, 86400000=1000*60*60*24.var workDayVal = (endDate - beginDate)/86400000 + 1;//The remainder of working hours var remains = workDayVal % 7; //The divisor that rounds downwards the working hours var divisor = Math.floor(workDayVal / 7);var weekendDay = 2 * divisor;//The week of the start date has the value (1,2,3,4,5,6,0) var nextDay = beginDate.getDay();//The week starts to traverse the remainder day for(var tempDay = remainder; tempDay>=1; tempDay--) { //Don't add 1 on the first day if(tempDay == remainder) { nextDay = nextDay + 0; } else if(tempDay != remainder) { nextDay = nextDay + 1; } //Sunday, changed to 0 if(nextDay == 7) { nextDay = 0; } //Saturday if(nextDay == 0 || nextDay == 6) { weekendDay = weekendDay + 1; }}// Actual working hours (days) = start and end date difference - the number of Saturday and Sundays. workDayVal = workDayVal - weekendDay;The simple example of calculating working days during two days in js is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.