I am trying to build a function in PHP that, depending on the date will give me
The current week (mon-sun) 20/8/12 to 26/8/12
Following week+1 (mon-sun) 27/8/12 to 02/9/12
Following week+2 (mon-sun) 03/9/12 to 09/9/12
Following week+3 (mon-sun)
Following week+4 (mon-sun)
Following week+5 (mon-sun)
I have tried using the following, but is there anything cleaner??
$week0_mon = date("Y-m-d", strtotime(date("Y").'W'.date('W')."1"));
$week0_sun = date("Y-m-d", strtotime(date("Y").'W'.date('W')."7"));
$week1_mon = date("Y-m-d", strtotime(date("Y-m-d", strtotime($week0_mon)) . " +1 week"));
$week1_sun = date("Y-m-d", strtotime(date("Y-m-d", strtotime($week0_sun)) . " +1 week"));
echo $week0_mon.' to '.$week0_sun.'<br />';
echo $week1_mon.' to '.$week1_sun.'<br />';
I did it like this. I’m not sure if it is exactly what you want.
From this you will get answer like this:
Following week+1 29/08/12 to 05/09/12
Following week+2 05/09/12 to 12/09/12
Following week+3 12/09/12 to 19/09/12
Following week+4 19/09/12 to 26/09/12
Following week+5 26/09/12 to 03/10/12
Following week+6 03/10/12 to 10/10/12