3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date = new DateTime("18-July-2008 16:30:30"); echo $date->format("d-m-Y H:i:s").'<br />'; date_sub($date, new DateInterval("P2H")); echo '<br />'.$date->format("d-m-Y").' : 2 Hours'; echo '<br />'.$date->format("d-m-Y").' : 5 Days'; date_sub($date, new DateInterval("P5Y5M5D")); echo '<br />'.$date->format("d-m-Y").' : 5 Days, 5 Months, 5 Years'; date_sub($date, new DateInterval("P5YT5H")); echo '<br />'.$date->format("d-m-Y H:i:s").' : 5 Years, 5 Hours'; ?>
Output for 7.0.0 - 7.1.0
18-07-2008 16:30:30<br /> Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (P2H) in /in/HcvNt:6 Stack trace: #0 /in/HcvNt(6): DateInterval->__construct('P2H') #1 {main} thrown in /in/HcvNt on line 6
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
18-07-2008 16:30:30<br /> Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct: Invalid interval (P2H)' in /in/HcvNt:6 Stack trace: #0 /in/HcvNt(6): DateInterval->__construct() #1 {main}
Process exited with code 255.
Output for 5.3.0 - 5.6.28
18-07-2008 16:30:30<br /> Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (P2H)' in /in/HcvNt:6 Stack trace: #0 /in/HcvNt(6): DateInterval->__construct('P2H') #1 {main} thrown in /in/HcvNt on line 6
Process exited with code 255.
Output for 5.2.0 - 5.2.17
18-07-2008 16:30:30<br /> Fatal error: Call to undefined function date_sub() in /in/HcvNt on line 6
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/HcvNt 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/HcvNt 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/HcvNt on line 3