I'm trying to generate a timestamp for each day of the week. My week starts Mon and ends Sun.
My code so far is below. Problem is that today (Sat), the generated timestamp for Sun is "last sunday", but it should be "next sunday".
I'm not sure what the best way is without using loads of if / else statements.
$today = time();
//$today = strtotime('next monday');
// If today is monday, generate timestamps for each day of the week starting today
if(date('D', $today) == 'Mon') {
$mon = $today;
$tue = strtotime('next tuesday');
$wed = strtotime('next wednesday');
$thu = strtotime('next thursday');
$fri = strtotime('next friday');
$sat = strtotime('next saturday');
$sun = strtotime('next sunday');
}
// Today is not monday, so generate timestamps for each day of the week, starting last monday
else {
$mon = strtotime('last monday');
$tue = (date('D', $today) == 'Tue') ? $today : strtotime('last tuesday');
$wed = (date('D', $today) == 'Wed') ? $today : strtotime('last wednesday');
$thu = (date('D', $today) == 'Thu') ? $today : strtotime('last thursday');
$fri = (date('D', $today) == 'Fri') ? $today : strtotime('last friday');
$sat = (date('D', $today) == 'Sat') ? $today : strtotime('last saturday');
$sun = (date('D', $today) == 'Sun') ? $today : strtotime('last sunday');
}