3v4l.org

run code in 300+ PHP versions simultaneously
<?php function work_days_between_two_dates(\DateTime $begin, \DateTime $end) { $workdays = []; $all_days = new DatePeriod($begin, new DateInterval('P1D'), $end->modify('+1 day')); foreach ($all_days as $day) { $dow = (int)$day->format('w'); $dom = (int)$day->format('j'); if (1 <= $dow && $dow <= 5) { // Mon - Fri $workdays[] = $day; } else if (6 == $dow && 0 == $dom % 2) { // Even Saturday $workdays[] = $day; } } return $workdays; } $begin = new \DateTime('2018-06-01'); $end = new \DateTime('2018-06-15'); $days = work_days_between_two_dates($begin, $end); foreach ($days as $day) { echo $day->format('Y-m-d') . PHP_EOL; }
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
2018-06-01 2018-06-02 2018-06-04 2018-06-05 2018-06-06 2018-06-07 2018-06-08 2018-06-11 2018-06-12 2018-06-13 2018-06-14 2018-06-15
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 2018-06-01 2018-06-02 2018-06-04 2018-06-05 2018-06-06 2018-06-07 2018-06-08 2018-06-11 2018-06-12 2018-06-13 2018-06-14 2018-06-15

preferences:
162.66 ms | 402 KiB | 162 Q