現在の日付について、前の日曜日から土曜日までの日付範囲を取得する方法が必要です。
たとえば、今日が 8/15 の場合、8/4 ~ 8/10 が必要です。
$to = new DateTime('2013-08-10');
$to->modify('-' . (($w = $to->format('w')) != 6 ? $w + 1 : 0) . ' day');
$from = clone $to;
$from->modify('-6 day');
echo $from->format('m/d') . "-" . $to->format('m/d'); # 08/04-08/10
$to = new DateTime('2013-08-10');
$to->modify('last Saturday');
$from = clone $to;
$from->modify('-6 day');
echo $from->format('m/d') . "-" . $to->format('m/d'); # 07/28-08/03
function getPreviousSundayAndSatruday($today = NULL)
{
$today = is_null($today) ? time() : $today;
// If today is Sunday, then find last week
if(date("w", $today) == 0){
$saturdayTimeStamp = strtotime("last Saturday");
$sundayTimeStamp = strtotime("last Sunday");
}
// If it is Saturday, check from last Sunday until today
else if(date("w", $today) == 6){
$saturdayTimeStamp = strtotime("this Saturday");
$sundayTimeStamp = strtotime("last Sunday");
}
// Else it's a day of the week, so last Saturday to two Sundays before.
else{
$saturdayTimeStamp = strtotime("last Saturday");
$sundayTimeStamp = strtotime("last Sunday - 1 week");
}
return array(
'saturday' => $saturdayTimeStamp,
'sunday' => $sundayTimeStamp
);
}