如何查找周之间的开始日期和结束日期
两个日期10-08-2016 and 25-08-2016
array['10-08-2016','16-08-2016'],array['17-08-2016','23-08-2016']
答案 0 :(得分:1)
你可以通过循环显示日期,找到每个日期的日期以及是否是星期一然后将其推入数组,如下所示:
$date = '10-08-2016';
$end_date = '25-08-2016';
$mondays = array();
while (strtotime($date) <= strtotime($end_date)) {
$day = date("l", strtotime($date));
if($day == 'Monday')
{
$mondays[] = $date;
}
$date = date ("d-m-Y", strtotime("+1 day", strtotime($date)));
}
print_r($mondays);
这会给你:
Array
(
[0] => 15-08-2016
[1] => 22-08-2016
)