Google is your friend.
https://rosettacode.org/wiki/Find_th...each_month#PHP
Like baodb said, you can use the string "last sunday of month year" in the date function to get the date of the last sunday.
date('Y-m-d', strtotime('last sunday of ' . $month . ' ' . $year)
Here is an example they have looping through and getting the last sunday of every month.
// Created with PHP 7.0
function printLastSundayOfAllMonth($year)
{
$months = array(
'January', 'February', 'March', 'April', 'June', 'July',
'August', 'September', 'October', 'November', 'December');
foreach ($months as $month) {
echo $month . ': ' . date('Y-m-d', strtotime('last sunday of ' . $month . ' ' . $year)) . "\n";
}
}
printLastSundayOfAllMonth($argv[1]);
.