3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getSundaysForTheMonth($y, $m) { return new DatePeriod( new DateTime("first sunday of $y-$m"), DateInterval::createFromDateString('next sunday'), new DateTime("last day of $y-$m 23:59:59") ); } // Get current Year and Month $currentYear = date('Y'); $currentMonth = date('m'); // Get month name $beginMonthName = date("F", mktime(0, 0, 0, $currentMonth, 10)); echo "Select which Sunday(s) of the month of ". $beginMonthName . " " . $currentYear . " :\n<BR>"; $i=0; // Display all Sundays for 3 months foreach (getSundaysForTheMonth($currentYear, $currentMonth) as $sunday) { $thisSunday = $sunday->format("m - d - Y"); echo "<input type=\"checkbox\" name=\"date[]\" value=\"$thisSunday\">$thisSunday\n<BR>"; $i++; }

preferences:
25.85 ms | 405 KiB | 5 Q