3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date_1 = new DateTime('2017-01-01'); $date_2 = new DateTime('2017-02-01'); $date_3 = new DateTime('2017-03-01'); $date_4 = new DateTime('2017-04-01'); $date_5 = new DateTime('2017-05-01'); $date_6 = new DateTime('2017-06-01'); $date_7 = new DateTime('2017-07-01'); $date_8 = new DateTime('2017-08-01'); $date_9 = new DateTime('2017-09-01'); $date_10 = new DateTime('2017-10-01'); $date_11 = new DateTime('2017-11-01'); $date_12 = new DateTime('2017-12-01'); $date_13 = new DateTime('2018-01-01'); echo $date_1->diff($date_2)->format('%m month, %d days') . "\n"; echo $date_2->diff($date_3)->format('%m month, %d days') . "\n"; echo $date_3->diff($date_4)->format('%m month, %d days') . "\n"; echo $date_4->diff($date_5)->format('%m month, %d days') . "\n"; echo $date_5->diff($date_6)->format('%m month, %d days') . "\n"; echo $date_6->diff($date_7)->format('%m month, %d days') . "\n"; echo $date_7->diff($date_8)->format('%m month, %d days') . "\n"; echo $date_8->diff($date_9)->format('%m month, %d days') . "\n"; echo $date_9->diff($date_10)->format('%m month, %d days') . "\n"; echo $date_10->diff($date_11)->format('%m month, %d days') . "\n"; echo $date_11->diff($date_12)->format('%m month, %d days') . "\n"; echo $date_12->diff($date_13)->format('%m month, %d days') . "\n";
Output for 7.3.32 - 7.3.33, 8.0.13, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days
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 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days 1 month, 0 days
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.29, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
1 month, 0 days 0 month, 28 days 1 month, 3 days 0 month, 30 days 1 month, 1 days 0 month, 30 days 1 month, 1 days 1 month, 0 days 0 month, 30 days 1 month, 1 days 0 month, 30 days 1 month, 1 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/1b6fj on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/1b6fj on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/1b6fj on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/1b6fj on line 16
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/1b6fj on line 16
Process exited with code 255.

preferences:
262.4 ms | 401 KiB | 390 Q