【发布时间】:2010-08-09 11:30:47
【问题描述】:
您好,我已经在使用另一个问题中的此代码 - 如果是周末,则会在结束日增加两天
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
【问题讨论】:
-
这个问题很混乱。也许您可以链接到前面的问题,以便为我们提供一些背景信息。
标签: php jquery datetime weekend