嗨,我已经在使用另一个问题的代码 - 在周末的情况下,它会在结束日增加两天
function add_business_days($startdate,$buisnessdays,$holidays,$dateformat){
$i=1;
$dayx = strtotime($startdate);
while($i < $buisnessdays){
$day = date('N',$dayx);
$datex = date('Y-m-d',$dayx);
if($day < 6 && !in_array($datex,$holidays))$i++;
$dayx = strtotime($datex.' +1 day');
}
return date($dateformat,$dayx);
}
此函数构成 json 输出的一部分,该输出显示在 jquery 日历中 - 它获取 startdate 和 enddate 并呈现它。
是否可以创建一个返回输出的代码,这样当它到达周末时它会创建一个结束日期,跳到星期一创建一个开始日期然后继续直到它达到原始给定的结束日期?
x = date('w');
if (x != 6) {
while (x != 6) {
//start adding days to start date
}
} else {
//create new enddate = current iteration of dates currentdate;
//then new start (add two days to it to get to monday) currentdate + 2 = newstartdate
//redo above till you get to original end date