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++; }
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Select which Sunday(s) of the month of August 2021 : <BR><input type="checkbox" name="date[]" value="08 - 01 - 2021">08 - 01 - 2021 <BR><input type="checkbox" name="date[]" value="08 - 08 - 2021">08 - 08 - 2021 <BR><input type="checkbox" name="date[]" value="08 - 15 - 2021">08 - 15 - 2021 <BR><input type="checkbox" name="date[]" value="08 - 22 - 2021">08 - 22 - 2021 <BR><input type="checkbox" name="date[]" value="08 - 29 - 2021">08 - 29 - 2021 <BR>

preferences:
46.33 ms | 408 KiB | 5 Q