3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date = '2014-03-31'; //$date = '2014-03-05'; print_r("date: $date"); $date = new DateTime($date); $date->add(new DateInterval('P3M')); $newExpireDate = $date->format('Y-m-d'); print_r("newExpireDate: $newExpireDate"); $date = new DateTime($newExpireDate); $date->sub(new DateInterval('P3M')); $newExpireDate = $date->format('Y-m-d'); print_r("newExpireDate: $newExpireDate");
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
date: 2014-03-31newExpireDate: 2014-07-01newExpireDate: 2014-04-01
Output for 5.2.0 - 5.2.17
date: 2014-03-31 Fatal error: Call to undefined method DateTime::add() in /in/mAXOE on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
date: 2014-03-31 Fatal error: Class 'DateTime' not found in /in/mAXOE on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
date: 2014-03-31 Fatal error: Cannot instantiate non-existent class: datetime in /in/mAXOE on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
date: 2014-03-31 Fatal error: Cannot instantiate non-existent class: datetime in /in/mAXOE on line 7