The
instance is as follows:
//start date, /pattern/is the definition of regular expression, pattern is the content to match, only for the first symbol match, G is the global match flag var begindate = new Date ("2013-01-01". Replace (/-/g, "/"));
End date var enddate = new Date ("2013-01-31". Replace (/-/g, "/"));
The date difference value, which contains the days of the week 6th, 86400000=1000*60*60*24.
var workdayval = (enddate-begindate)/86400000 + 1;
The remainder of the work var remainder = workdayval% 7;//Work down the divisor var divisor = Math.floor (WORKDAYVAL/7);
var weekendday = 2 * DIVISOR;
Week of starting date, week value has (1,2,3,4,5,6,0) var nextday = Begindate.getday (); Start the week from the start date to traverse remainder day for (var tempday = remainder; tempday>=1; tempday--) {//First day without adding 1 if (tempday = remainder)
{nextday = nextday + 0;
else if (tempday!= remainder) {nextday = nextday + 1;
//Sunday, change to 0 if (NextDay = 7) {nextday = 0;
//week 6th if (nextday = 0 | | nextday = = 6) {Weekendday = weekendday + 1;
}//Actual work (days) = end to End date difference-number of weeks 6th.
Workdayval = Workdayval-weekendday;
This JS in the calculation of two days during the working day of the simple example is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.