3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "blah 2014 yar"; $pos = strpos($string, "20"); $year = substr($string, $pos, 4); echo $year; $date1 = new DateTime($year); var_dump($date1); ?>
based on qGEUa
Output for 5.4.30 - 5.4.32, 5.6.28, 7.0.14 - 7.1.0
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2014-10-02 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.6
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-03 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.14, 7.0.5
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-02 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.4
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-10 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.3
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.2
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-22 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.1
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-23 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.0
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-26 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for hhvm-3.12.0
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-12 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for hhvm-3.10.0
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-30 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.21
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-02 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.20
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-09 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.19
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-07 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.18
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-15 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.17
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-19 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.16
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-28 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.15
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-29 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.13
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.12
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-19 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.11
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-23 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.10
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-25 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.9
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-27 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.8
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-29 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.35
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-22 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.34
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-11 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.33
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-08 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.32
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-17 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.31
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-20 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.30
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-01 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.29
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-16 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.28
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-21 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.27
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-22 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.26
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-26 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.25
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-28 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.24
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-23 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.39 - 5.4.45
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-20 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.34 - 5.4.38
2014object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-15 20:14:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.0 - 5.4.29
2014object(DateTime)#1 (3) { ["date"]=> string(19) "2014-10-02 20:14:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.2.0 - 5.2.17
2014object(DateTime)#1 (0) { }
Output for 5.0.0 - 5.1.6
2014 Fatal error: Class 'DateTime' not found in /in/60oPT on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
2014 Fatal error: Cannot instantiate non-existent class: datetime in /in/60oPT on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
2014 Fatal error: Cannot instantiate non-existent class: datetime in /in/60oPT on line 7