Get first and last day of the last week

Hello guys!

How can I get the first (monday) and the last (sunday) day of the last week?

Thanks!

Do you mean the dates of them?


$Sunday = Date('d/m/y', StrToTime("Next Sunday"));
$Monday = Date('d/m/y', StrToTime("Last Monday"));

[edit]Though that’d have problems on Sundays and Mondays, so you could try:

$Current = Date('N');
$DaysToSunday = 7 - $Current;
$DaysFromMonday = $Current - 1;
$Sunday = Date('d/m/y', StrToTime("+ {$DaysToSunday} Days"));
$Monday = Date('d/m/y', StrToTime("- {$DaysFromMonday} Days"));

[/edit]

Yes, the dates. Works like a charm, thanks!

If you mean “of the last full week”, then you could do:


$monday = date('d/m/y', strtotime('monday last week'));
$sunday = date('d/m/y', strtotime('sunday last week'));