こんにちはすでに私は別の質問からこのコードを使用しています-週末の場合は終了日に2日余分に追加されます
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);
}
この関数は、jqueryカレンダーに表示されるjson出力の一部を形成します。つまり、開始日と終了日を取得してレンダリングします。
週末になると終了日を作成し、月曜日にスキップして開始日を作成し、元の指定された終了日に達するまで続行するような出力を返すコードを作成することは可能ですか?
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