3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime(); $end = new DateTime('tomorrow'); $middle = ($end->getTimestamp()-$start->getTimestamp())/2; $final = new DateTime('+'.$middle.'sec'); var_dump($final);
Output for 7.3.0rc4
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002623" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0rc3
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.004541" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0rc2
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.005187" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0rc1
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.005300" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0beta3
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002472" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0beta2
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001683" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0beta1
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002087" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0alpha4
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002125" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0alpha3
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001712" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0alpha2
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003975" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0alpha1
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003517" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.11
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003512" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.10
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.004959" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.9
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002604" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.8
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003795" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.7
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003292" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.6
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003529" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.5
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.004154" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.4
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003003" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.3
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002792" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.2
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002208" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.1
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002141" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.0
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002494" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.23
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002439" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.22
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002042" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.21
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003543" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.20
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002634" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.19
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.005271" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.18
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.004444" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.17
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003153" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.16
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001931" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.15
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003022" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.14
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002443" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.13
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001867" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.12
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001876" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.11
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002705" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.10
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001944" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.9
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.003562" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.8
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001949" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.7
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002846" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.6
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.007798" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.007235" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.4
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.006732" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.6.38, hhvm-3.10.1 - 3.18.5, hhvm-3.20.2 - 3.22.0, 7.0.0 - 7.0.31, 7.1.3
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.2
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.007058" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.1
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.002496" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0
object(DateTime)#3 (3) { ["date"]=> string(26) "2013-01-12 17:55:28.001905" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for hhvm-3.19.2
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (+21871.5sec) at position 4 (7): Unexpected character' in /in/3HAJp:7 Stack trace: #0 /in/3HAJp(7): DateTime->__construct() #1 {main}
Process exited with code 255.
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
object(DateTime)#3 (3) { ["date"]=> string(19) "2013-01-12 17:55:28" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::getTimestamp() in /in/3HAJp on line 5
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/3HAJp on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/3HAJp on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/3HAJp on line 2