3v4l.org

run code in 300+ PHP versions simultaneously
<?php $correctTimestamp = correctMondayTimestamp(); $time_query = "data_ordine BETWEEN DATE('".date("Y-m-d",$correctTimestamp)."') AND DATE_ADD(DATE('".date("Y-m-d",strtotime("sunday this week"))."'), INTERVAL 1 DAY)"; $begin = new DateTime(date("c", $correctTimestamp)); echo "TQ: $time_query\nB: ".date_format('U',$begin); function correctMondayTimestamp(){ if(date('N') == 7) { return strtotime('monday last week'); } else { return strtotime('monday this week'); } }
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 TypeError: date_format(): Argument #1 ($object) must be of type DateTimeInterface, string given in /in/mlUTN:6 Stack trace: #0 /in/mlUTN(6): date_format('U', Object(DateTime)) #1 {main} thrown in /in/mlUTN on line 6
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 TypeError: date_format(): Argument #1 ($object) must be of type DateTimeInterface, string given in /in/mlUTN:6 Stack trace: #0 /in/mlUTN(6): date_format('U', Object(DateTime)) #1 {main} thrown in /in/mlUTN on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in /in/mlUTN on line 6 TQ: data_ordine BETWEEN DATE('2017-06-19') AND DATE_ADD(DATE('2017-06-25'), INTERVAL 1 DAY) B:

preferences:
157.66 ms | 402 KiB | 172 Q