3v4l.org

run code in 300+ PHP versions simultaneously
<?php $workdays = array(); $type = CAL_GREGORIAN; $month = date('n'); // Month ID, 1 through to 12. $year = date('Y'); // Year in 4 digit 2009 format. $day_count = cal_days_in_month($type, $month, $year); // Get the amount of days $current_date = date('Y/n/j'); //loop through all days for ($i = 1; $i <= $day_count; $i++) { $date = $year.'/'.$month.'/'.$i; //format date $get_name = date('l', strtotime($date)); //get week day $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars //if not a weekend add day to array if($day_name != 'Sun' && $day_name != 'Sat' && $date <= $current_date){ $workdays[] = $date; } } foreach($workdays as $bd){ echo $bd.'<br>'; }
Output for 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
Fatal error: Uncaught Error: Undefined constant "CAL_GREGORIAN" in /in/7A3It:4 Stack trace: #0 {main} thrown in /in/7A3It on line 4
Process exited with code 255.
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 Fatal error: Uncaught Error: Undefined constant "CAL_GREGORIAN" in /in/7A3It:4 Stack trace: #0 {main} thrown in /in/7A3It on line 4
Process exited with code 255.
Output for 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant CAL_GREGORIAN - assumed 'CAL_GREGORIAN' (this will throw an Error in a future version of PHP) in /in/7A3It on line 4 Fatal error: Uncaught Error: Call to undefined function cal_days_in_month() in /in/7A3It:7 Stack trace: #0 {main} thrown in /in/7A3It on line 7
Process exited with code 255.
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0
2016/5/10<br>2016/5/11<br>2016/5/12<br>2016/5/13<br>
Output for 7.1.20
Notice: Use of undefined constant CAL_GREGORIAN - assumed 'CAL_GREGORIAN' in /in/7A3It on line 4 Fatal error: Uncaught Error: Call to undefined function cal_days_in_month() in /in/7A3It:7 Stack trace: #0 {main} thrown in /in/7A3It on line 7
Process exited with code 255.

preferences:
177.62 ms | 401 KiB | 219 Q