我正在尝试使用 PHP 确定从周一到周日的周范围。我能够计算周数,但我无法获得每周正确的结束周范围。
这是我到目前为止所拥有的:
$start_date = 1337621424;
$end_date = 1349964545;
$start_week = (int)date('W', $start_date);
$end_week = (int)date('W', $end_date);
echo "START WEEK: " . $start_week . "<BR>";
echo "END WEEK: " . $end_week . "<BR>";
$dates = array();
if ($start_week && $end_week) {
for ($week=$start_week; $week<=$end_week; $week++) {
echo "WEEK: " . $week . "<BR>";
$startdate = strtotime ( '- ' . $week. ' week', strtotime ( date('Y-m-d') ) ) ;
$startdate = date ( 'Y-m-d' , $startdate );
//$end = date('Y-m-d');
$end = strtotime ( '- ' . ($week + 1) . ' week', strtotime ( $startdate ) ) ;
$end = date ( 'Y-m-d' , $end );
$dates[$week]['start'] = $startdate;
$dates[$week]['end'] = $end;
}
print_r($dates);
}
知道我缺少什么或者有更简单的方法吗?