3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php header('Content-Type: text/plain; charset=utf-8'); echo $currentDate = "2013-10-31", PHP_EOL; $date = DateTime::createFromFormat('Y-m-d', $currentDate); $date->sub(new DateInterval('P1M')); echo $date->format('Y-m-d'), PHP_EOL; $date->add(new DateInterval('P1M')); echo $date->format('Y-m-d'), PHP_EOL; ?>
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2013-10-31 2013-10-01 2013-11-01
Output for 5.2.10 - 5.2.17
2013-10-31 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/XcAu2 on line 6
Process exited with code 255.
Output for 5.2.0 - 5.2.9
2013-10-31 Fatal error: Call to undefined method DateTime::createfromformat() in /in/XcAu2 on line 6
Process exited with code 255.
Output for 5.0.2 - 5.1.6
2013-10-31 Fatal error: Class 'DateTime' not found in /in/XcAu2 on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.1
2013-10-31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/XcAu2 on line 4 PHP_EOL Fatal error: Class 'DateTime' not found in /in/XcAu2 on line 6
Process exited with code 255.
Output for 4.3.10 - 4.4.9
2013-10-31 Fatal error: Undefined class name 'datetime' in /in/XcAu2 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.9
2013-10-31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/XcAu2 on line 4 PHP_EOL Fatal error: Undefined class name 'datetime' in /in/XcAu2 on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
2013-10-31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/XcAu2 on line 4 PHP_EOL Fatal error: Undefined class name 'datetime' in /in/XcAu2 on line 6