3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date = new DateTime('2014-03-12'); $comp = new DateTime('2014-03-11'); while ($date >= new DateTime('2014-01-01')) { $diff = $comp->diff($date); echo $comp->format('Y-m-d H:i:s'), ' - ', $date->format('Y-m-d H:i:s'), ' = ', $diff->format('%r%Y-%M-%D %H:%I:%S'), ' = ', $diff->format('%r%a'), " days\n"; $date->sub(new DateInterval('P1D')); }
Output for 5.3.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2014-03-11 00:00:00 - 2014-03-12 00:00:00 = 00-00-01 00:00:00 = 1 days 2014-03-11 00:00:00 - 2014-03-11 00:00:00 = 00-00-00 00:00:00 = 0 days 2014-03-11 00:00:00 - 2014-03-10 00:00:00 = -00-00-01 00:00:00 = -1 days 2014-03-11 00:00:00 - 2014-03-09 00:00:00 = -00-00-02 00:00:00 = -2 days 2014-03-11 00:00:00 - 2014-03-08 00:00:00 = -00-00-03 00:00:00 = -3 days 2014-03-11 00:00:00 - 2014-03-07 00:00:00 = -00-00-04 00:00:00 = -4 days 2014-03-11 00:00:00 - 2014-03-06 00:00:00 = -00-00-05 00:00:00 = -5 days 2014-03-11 00:00:00 - 2014-03-05 00:00:00 = -00-00-06 00:00:00 = -6 days 2014-03-11 00:00:00 - 2014-03-04 00:00:00 = -00-00-07 00:00:00 = -7 days 2014-03-11 00:00:00 - 2014-03-03 00:00:00 = -00-00-08 00:00:00 = -8 days 2014-03-11 00:00:00 - 2014-03-02 00:00:00 = -00-00-09 00:00:00 = -9 days 2014-03-11 00:00:00 - 2014-03-01 00:00:00 = -00-00-10 00:00:00 = -10 days 2014-03-11 00:00:00 - 2014-02-28 00:00:00 = -00-00-11 00:00:00 = -11 days 2014-03-11 00:00:00 - 2014-02-27 00:00:00 = -00-00-12 00:00:00 = -12 days 2014-03-11 00:00:00 - 2014-02-26 00:00:00 = -00-00-13 00:00:00 = -13 days 2014-03-11 00:00:00 - 2014-02-25 00:00:00 = -00-00-14 00:00:00 = -14 days 2014-03-11 00:00:00 - 2014-02-24 00:00:00 = -00-00-15 00:00:00 = -15 days 2014-03-11 00:00:00 - 2014-02-23 00:00:00 = -00-00-16 00:00:00 = -16 days 2014-03-11 00:00:00 - 2014-02-22 00:00:00 = -00-00-17 00:00:00 = -17 days 2014-03-11 00:00:00 - 2014-02-21 00:00:00 = -00-00-18 00:00:00 = -18 days 2014-03-11 00:00:00 - 2014-02-20 00:00:00 = -00-00-19 00:00:00 = -19 days 2014-03-11 00:00:00 - 2014-02-19 00:00:00 = -00-00-20 00:00:00 = -20 days 2014-03-11 00:00:00 - 2014-02-18 00:00:00 = -00-00-21 00:00:00 = -21 days 2014-03-11 00:00:00 - 2014-02-17 00:00:00 = -00-00-22 00:00:00 = -22 days 2014-03-11 00:00:00 - 2014-02-16 00:00:00 = -00-00-23 00:00:00 = -23 days 2014-03-11 00:00:00 - 2014-02-15 00:00:00 = -00-00-24 00:00:00 = -24 days 2014-03-11 00:00:00 - 2014-02-14 00:00:00 = -00-00-25 00:00:00 = -25 days 2014-03-11 00:00:00 - 2014-02-13 00:00:00 = -00-00-26 00:00:00 = -26 days 2014-03-11 00:00:00 - 2014-02-12 00:00:00 = -00-00-27 00:00:00 = -27 days 2014-03-11 00:00:00 - 2014-02-11 00:00:00 = -00-01-00 00:00:00 = -28 days 2014-03-11 00:00:00 - 2014-02-10 00:00:00 = -00-01-01 00:00:00 = -29 days 2014-03-11 00:00:00 - 2014-02-09 00:00:00 = -00-01-02 00:00:00 = -30 days 2014-03-11 00:00:00 - 2014-02-08 00:00:00 = -00-01-03 00:00:00 = -31 days 2014-03-11 00:00:00 - 2014-02-07 00:00:00 = -00-01-04 00:00:00 = -32 days 2014-03-11 00:00:00 - 2014-02-06 00:00:00 = -00-01-05 00:00:00 = -33 days 2014-03-11 00:00:00 - 2014-02-05 00:00:00 = -00-01-06 00:00:00 = -34 days 2014-03-11 00:00:00 - 2014-02-04 00:00:00 = -00-01-07 00:00:00 = -35 days 2014-03-11 00:00:00 - 2014-02-03 00:00:00 = -00-01-08 00:00:00 = -36 days 2014-03-11 00:00:00 - 2014-02-02 00:00:00 = -00-01-09 00:00:00 = -37 days 2014-03-11 00:00:00 - 2014-02-01 00:00:00 = -00-01-10 00:00:00 = -38 days 2014-03-11 00:00:00 - 2014-01-31 00:00:00 = -00-01-11 00:00:00 = -39 days 2014-03-11 00:00:00 - 2014-01-30 00:00:00 = -00-01-12 00:00:00 = -40 days 2014-03-11 00:00:00 - 2014-01-29 00:00:00 = -00-01-13 00:00:00 = -41 days 2014-03-11 00:00:00 - 2014-01-28 00:00:00 = -00-01-14 00:00:00 = -42 days 2014-03-11 00:00:00 - 2014-01-27 00:00:00 = -00-01-15 00:00:00 = -43 days 2014-03-11 00:00:00 - 2014-01-26 00:00:00 = -00-01-16 00:00:00 = -44 days 2014-03-11 00:00:00 - 2014-01-25 00:00:00 = -00-01-17 00:00:00 = -45 days 2014-03-11 00:00:00 - 2014-01-24 00:00:00 = -00-01-18 00:00:00 = -46 days 2014-03-11 00:00:00 - 2014-01-23 00:00:00 = -00-01-19 00:00:00 = -47 days 2014-03-11 00:00:00 - 2014-01-22 00:00:00 = -00-01-20 00:00:00 = -48 days 2014-03-11 00:00:00 - 2014-01-21 00:00:00 = -00-01-21 00:00:00 = -49 days 2014-03-11 00:00:00 - 2014-01-20 00:00:00 = -00-01-22 00:00:00 = -50 days 2014-03-11 00:00:00 - 2014-01-19 00:00:00 = -00-01-23 00:00:00 = -51 days 2014-03-11 00:00:00 - 2014-01-18 00:00:00 = -00-01-24 00:00:00 = -52 days 2014-03-11 00:00:00 - 2014-01-17 00:00:00 = -00-01-25 00:00:00 = -53 days 2014-03-11 00:00:00 - 2014-01-16 00:00:00 = -00-01-26 00:00:00 = -54 days 2014-03-11 00:00:00 - 2014-01-15 00:00:00 = -00-01-27 00:00:00 = -55 days 2014-03-11 00:00:00 - 2014-01-14 00:00:00 = -00-01-28 00:00:00 = -56 days 2014-03-11 00:00:00 - 2014-01-13 00:00:00 = -00-01-29 00:00:00 = -57 days 2014-03-11 00:00:00 - 2014-01-12 00:00:00 = -00-01-30 00:00:00 = -58 days 2014-03-11 00:00:00 - 2014-01-11 00:00:00 = -00-02-00 00:00:00 = -59 days 2014-03-11 00:00:00 - 2014-01-10 00:00:00 = -00-02-01 00:00:00 = -60 days 2014-03-11 00:00:00 - 2014-01-09 00:00:00 = -00-02-02 00:00:00 = -61 days 2014-03-11 00:00:00 - 2014-01-08 00:00:00 = -00-02-03 00:00:00 = -62 days 2014-03-11 00:00:00 - 2014-01-07 00:00:00 = -00-02-04 00:00:00 = -63 days 2014-03-11 00:00:00 - 2014-01-06 00:00:00 = -00-02-05 00:00:00 = -64 days 2014-03-11 00:00:00 - 2014-01-05 00:00:00 = -00-02-06 00:00:00 = -65 days 2014-03-11 00:00:00 - 2014-01-04 00:00:00 = -00-02-07 00:00:00 = -66 days 2014-03-11 00:00:00 - 2014-01-03 00:00:00 = -00-02-08 00:00:00 = -67 days 2014-03-11 00:00:00 - 2014-01-02 00:00:00 = -00-02-09 00:00:00 = -68 days 2014-03-11 00:00:00 - 2014-01-01 00:00:00 = -00-02-10 00:00:00 = -69 days
Output for 5.3.0 - 5.3.2
2014-03-11 00:00:00 - 2014-03-12 00:00:00 = 00-00-01 00:00:00 = 1 days 2014-03-11 00:00:00 - 2014-03-10 00:00:00 = -00-00-01 00:00:00 = -1 days 2014-03-11 00:00:00 - 2014-03-08 00:00:00 = -00-00-03 00:00:00 = -3 days 2014-03-11 00:00:00 - 2014-03-06 00:00:00 = -00-00-05 00:00:00 = -5 days 2014-03-11 00:00:00 - 2014-03-04 00:00:00 = -00-00-07 00:00:00 = -7 days 2014-03-11 00:00:00 - 2014-03-02 00:00:00 = -00-00-09 00:00:00 = -9 days 2014-03-11 00:00:00 - 2014-02-28 00:00:00 = -00-00-11 00:00:00 = -11 days 2014-03-11 00:00:00 - 2014-02-26 00:00:00 = -00-00-13 00:00:00 = -13 days 2014-03-11 00:00:00 - 2014-02-24 00:00:00 = -00-00-15 00:00:00 = -15 days 2014-03-11 00:00:00 - 2014-02-22 00:00:00 = -00-00-17 00:00:00 = -17 days 2014-03-11 00:00:00 - 2014-02-20 00:00:00 = -00-00-19 00:00:00 = -19 days 2014-03-11 00:00:00 - 2014-02-18 00:00:00 = -00-00-21 00:00:00 = -21 days 2014-03-11 00:00:00 - 2014-02-16 00:00:00 = -00-00-23 00:00:00 = -23 days 2014-03-11 00:00:00 - 2014-02-14 00:00:00 = -00-00-25 00:00:00 = -25 days 2014-03-11 00:00:00 - 2014-02-12 00:00:00 = -00-00-27 00:00:00 = -27 days 2014-03-11 00:00:00 - 2014-02-10 00:00:00 = -00-01-01 00:00:00 = -29 days 2014-03-11 00:00:00 - 2014-02-08 00:00:00 = -00-01-03 00:00:00 = -31 days 2014-03-11 00:00:00 - 2014-02-06 00:00:00 = -00-01-05 00:00:00 = -33 days 2014-03-11 00:00:00 - 2014-02-04 00:00:00 = -00-01-07 00:00:00 = -35 days 2014-03-11 00:00:00 - 2014-02-02 00:00:00 = -00-01-09 00:00:00 = -37 days 2014-03-11 00:00:00 - 2014-01-31 00:00:00 = -00-01-11 00:00:00 = -39 days 2014-03-11 00:00:00 - 2014-01-29 00:00:00 = -00-01-13 00:00:00 = -41 days 2014-03-11 00:00:00 - 2014-01-27 00:00:00 = -00-01-15 00:00:00 = -43 days 2014-03-11 00:00:00 - 2014-01-25 00:00:00 = -00-01-17 00:00:00 = -45 days 2014-03-11 00:00:00 - 2014-01-23 00:00:00 = -00-01-19 00:00:00 = -47 days 2014-03-11 00:00:00 - 2014-01-21 00:00:00 = -00-01-21 00:00:00 = -49 days 2014-03-11 00:00:00 - 2014-01-19 00:00:00 = -00-01-23 00:00:00 = -51 days 2014-03-11 00:00:00 - 2014-01-17 00:00:00 = -00-01-25 00:00:00 = -53 days 2014-03-11 00:00:00 - 2014-01-15 00:00:00 = -00-01-27 00:00:00 = -55 days 2014-03-11 00:00:00 - 2014-01-13 00:00:00 = -00-02-01 00:00:00 = -57 days 2014-03-11 00:00:00 - 2014-01-11 00:00:00 = -00-02-00 00:00:00 = -59 days 2014-03-11 00:00:00 - 2014-01-09 00:00:00 = -00-02-02 00:00:00 = -61 days 2014-03-11 00:00:00 - 2014-01-07 00:00:00 = -00-02-04 00:00:00 = -63 days 2014-03-11 00:00:00 - 2014-01-05 00:00:00 = -00-02-06 00:00:00 = -65 days 2014-03-11 00:00:00 - 2014-01-03 00:00:00 = -00-02-08 00:00:00 = -67 days 2014-03-11 00:00:00 - 2014-01-01 00:00:00 = -00-02-10 00:00:00 = -69 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/fPeCq on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/fPeCq on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/fPeCq on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/fPeCq on line 3