3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "blah 2015 yar"; $pos = strpos($string, "20"); $year = substr($string, $pos, 4); echo $year . "<br />\n"; $end_year = "12/31/" . $year; $end_time = new DateTime($end_year); $start_time = new DateTime(); $diff = $end_time->date ->diff($start_time->date); var_dump($diff); ?>
based on 2L6rT
Output for 7.0.0 - 7.1.0
2015<br /> Notice: Undefined property: DateTime::$date in /in/BLFYZ on line 10 Fatal error: Uncaught Error: Call to a member function diff() on null in /in/BLFYZ:10 Stack trace: #0 {main} thrown in /in/BLFYZ on line 10
Process exited with code 255.
Output for 5.6.8 - 5.6.28
2015<br /> Notice: Undefined property: DateTime::$date in /in/BLFYZ on line 10 Fatal error: Call to a member function diff() on null in /in/BLFYZ on line 10
Process exited with code 255.
Output for 5.2.6 - 5.5.35
2015<br /> Notice: Undefined property: DateTime::$date in /in/BLFYZ on line 10 Fatal error: Call to a member function diff() on a non-object in /in/BLFYZ on line 10
Process exited with code 255.
Output for 5.2.0 - 5.2.5
2015<br /> Notice: Undefined property: DateTime::$date in /in/BLFYZ on line 10 Fatal error: Call to a member function diff() on a non-object in /in/BLFYZ on line 10
Process exited with code 255.
Output for 5.0.0 - 5.1.6
2015<br /> Fatal error: Class 'DateTime' not found in /in/BLFYZ on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.9
2015<br /> Fatal error: Cannot instantiate non-existent class: datetime in /in/BLFYZ on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
2015<br /> Fatal error: Cannot instantiate non-existent class: datetime in /in/BLFYZ on line 8