Version: 1.0
Type: Function
Category: Calendars/Dates
License: GNU Library Public License
Description: This function returns the date of the last sunday from the current date in the form dd/mm/yyyy
<?php function last_sunday() { ///////////////////////////////////////////////////// //This function returns the date of the last sunday// //from the current date in the form dd/mm/yyyy // ///////////////////////////////////////////////////// $today = date("j"); $last_sunday_day = $today - date("w"); $last_sunday = $last_sunday_day."/".date("n")."/".date("Y"); if($last_sunday < 1) { $last_month = date("n") - 1; if($last_month < 1) { $last_month = 12; $last_year = date("Y") - 1; $no_days_last_month = date("t", mktime(0,0,0,$last_month,1,$last_year)); $last_sunday_day = $no_days_last_month + $last_sunday; $last_sunday = $last_sunday_day."/".$last_month."/".$last_year; } else { $no_days_last_month = date("t", mktime(0,0,0,$last_month)); $last_sunday_day = $no_days_last_month + $last_sunday; $last_sunday = $last_sunday_day."/".$last_month."/".date("Y"); } } return $last_sunday; } echo "last_sunday = ". last_sunday() ."<br>n"; ?>