$day = date('l', strtotime('07/25/2010'));
echo "$day ";
echo date("m/d/Y", strtotime("first $day"));
This prints out Sunday 07/11/2010
$day = date('l', strtotime('07/25/2010'));
echo "$day ";
echo date("m/d/Y", strtotime("last $day"));
This prints out Sunday 07/04/2010
What’s going on here? Shouldn’t it be 07/04/2010 and 07/25/2010 respectively?
I think the answers are correct, because they are relative to the given date (which when not given defaults to today).
Based on the PHP docs:
So FIRST SUNDAY is in fact the 11th, and LAST SUNDAY was in fact the 4th. Based on the wording of your question, it appears you are looking for the 1st Sunday of the month, and the last Sunday of the month. This function returns the first Sunday AFTER today, and the LAST Sunday before today.