Reputation: 543
I have a script which gets the monday of the week to be able to display a calendar by using a while loop, so it gets the monday of that week then list out 7 divs which correspond to a day of the week.
I thought it was working but today(sunday) it has start listing the week starting tomorrow(monday) why is this? the code I have is:
$days = date("j",strtotime("monday this week"));
That variable returns 8, meaning PHP thinks the week starts on a sunday?
Upvotes: 2
Views: 86
Reputation: 43552
You are better of relying on ISO8601 standard:
$dt = new DateTime();
$dt->setISODate($dt->format('o'), $dt->format('W'));
echo $dt->format('Y-m-j');
Upvotes: 0
Reputation: 59681
This should work for you:
echo $monday = date("j",strtotime('last monday', strtotime('tomorrow')));
Output:
1
Upvotes: 1