3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = new \DateTime('1/1/2012'); foreach(range(1, 12) as $i) { $a->modify('+1 month'); } echo $a->format('m/d/Y'), PHP_EOL; $b = new \DateTime('1/1/2012'); foreach(range(1, 12) as $i) { $b->modify('+30 days'); } echo $b->format('m/d/Y'), PHP_EOL; echo $a->diff($b)->format('%a'), PHP_EOL;
Output for 5.3.0 - 7.1.0
01/01/2013 12/26/2012 6
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 10 01/01/2013 12/26/2012 Fatal error: Call to undefined method DateTime::diff() in /in/NUhjP on line 17
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 10 Fatal error: Class 'DateTime' not found in /in/NUhjP on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 10 Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/NUhjP on line 17
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 10 Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/NUhjP on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NUhjP on line 10 Parse error: parse error, expecting `','' or `';'' in /in/NUhjP on line 17
Process exited with code 255.
Output for 4.3.0
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/R8I2f on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/R8I2f on line 10 Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/R8I2f on line 17
Process exited with code 255.