View Full Version : is it possible to find the date of the last sunday from todays date?

11-26-2010, 12:30 AM
Hi All

i am trying to find out how to find out the date of the most recent sunday from the current date.

for example lets take today its 25/11/2010 but i am trying to find out last sundays date which was 21/11/2010. how would i go about doing this?

i would want this to work for any future date so tomorrow i want it to work and find the same date 21/11/2010 :) also if today is a sunday then i want it to return todays date, if that makes sence

many thanks

11-26-2010, 12:38 AM
Sure, you use strtotime.

$lastSunday = strtotime('last sunday');
print date('Y/m/d', $lastSunday);

Same goes for the future or past. Strtotime works on relative dates, using '+/-# day' like +1 day, and minor relatives such as 'today', 'yesterday', and 'tomorrow', 'last X', and 'next X', where X is a day of the week.

11-26-2010, 12:44 AM
sweet! thanks so much mate,