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 - 7.1.0
date: 2014-03-31newExpireDate: 2014-07-01newExpireDate: 2014-04-01
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 15 date: 2014-03-31 Fatal error: Call to undefined method DateTime::add() in /in/lHK5Q on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 15 date: 2014-03-31 Fatal error: Class 'DateTime' not found in /in/lHK5Q on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 15 date: 2014-03-31 Fatal error: Cannot instantiate non-existent class: datetime in /in/lHK5Q on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 8 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lHK5Q on line 15 date: 2014-03-31 Fatal error: Cannot instantiate non-existent class: datetime in /in/lHK5Q on line 7