3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(getFirstDayInMonth(new DateTime())); function getFirstDayInMonth($date) { $firstDayInMonth = $date->modify("first day of this month"); if($firstDayInMonth->format("Y-m-d") == date("Y-m-d", easter_date($firstDayInMonth->format($firstDayInMonth->format("Y"))))) $firstDayInMonth->modify("+2 days"); // posunutí z neděle na úterý if($firstDayInMonth->format($firstDayInMonth->format("Y")) == 2024) $firstDayInMonth->modify("+1 day"); // 1. leden if($firstDayInMonth == new DateTime("1.1.".$firstDayInMonth->format("Y"))) $firstDayInMonth->modify("+1 day"); // 1. květen print_r($firstDayInMonth); print_r(new DateTime($firstDayInMonth->format("Y") . "-05-01")); if($firstDayInMonth == new DateTime($firstDayInMonth->format("Y") . "-05-01")) $firstDayInMonth->modify("+1 day"); // zjištění dnu v týdnu $numberOfDay = $firstDayInMonth->format("w"); //sobota if($numberOfDay == 6) $firstDayInMonth = $firstDayInMonth->modify("+2 days"); // neděle if($numberOfDay == 0) // ne $firstDayInMonth = $firstDayInMonth->modify("+1 day"); return $firstDayInMonth; }
Output for 7.3.24 - 7.3.33, 7.4.12 - 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.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Fatal error: Uncaught Error: Call to undefined function easter_date() in /in/dYgTE:9 Stack trace: #0 /in/dYgTE(3): getFirstDayInMonth(Object(DateTime)) #1 {main} thrown in /in/dYgTE on line 9
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.2.3
DateTime Object ( [date] => 2018-05-01 12:17:07.004953 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2018-05-01 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTime Object ( [date] => 2018-05-01 12:17:07.004953 [timezone_type] => 3 [timezone] => Europe/Amsterdam )

preferences:
199.92 ms | 409 KiB | 5 Q