【发布时间】:2012-05-15 06:49:51
【问题描述】:
我有一个函数可以返回数组中两个日期之间的所有日期,但我需要在该数组中排除星期日。
public function dateRange($first, $last, $step = '+1 day', $format = 'd/m/Y' ) {
$dates = array();
$current = strtotime($first);
$last = strtotime($last);
while( $current <= $last ) {
$dates[] = date($format, $current);
$current = strtotime($step, $current);
}
return $dates;
}
排除星期日后,我有一个表格,我将在其中存储一些日期,我也需要从数组中排除这些日期。
例如,如果我输入的日期范围为 01-05-2012(DD-MM-YYYY) 到 10-05-2012, 06-05-2012 将是星期日,日期 01-05-2012 和 08-05-2012 将在我上面提到的表格中, 最终的输出应该是这样的,
02-05-2012
03-05-2012
04-05-2012
05-05-2012
07-05-2012
09-05-2012
10-05-2012
如何在 PHP 中做到这一点? 我尝试了一些,但找不到正确的方法。
【问题讨论】:
标签: php date date-range