3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Create two identical DateTime objects $a = new DateTime("2015-02-01 00:00:00", new DateTimeZone("PST")); $b = clone $a; // They should be equal (and they are) compare($a, $b); // Now change the timezone to EST. $b->setTimezone(new DateTimeZone("EST")); //The actual timestamp should not change (it does not in PHP 5.4) so $a should still be equal to $b, but it will say $a > $b. compare($a, $b); function compare($a, $b) { var_dump($a); var_dump($b); echo ($a > $b ? '$a > $b' : ($a < $b ? '$a < $b' : ($a == $b ? '$a == $b' : 'undefined'))) . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-02-01 00:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "PST" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-02-01 00:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "PST" } $a == $b object(DateTime)#1 (3) { ["date"]=> string(26) "2015-02-01 00:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "PST" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-02-01 03:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "EST" } $a == $b

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
59.04 ms | 402 KiB | 8 Q