3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ini_set("precision", 20); $expected = new DateTimeImmutable('2015-08-31 01:02:04.456790'); var_dump($expected); var_dump($expected->getTimestamp()); $date2 = new DateTimeImmutable('2015-08-31 01:02:03.456788'); $date2 = $date2->modify('1 seconds 2 microseconds'); var_dump($date2); var_dump($date2->getTimestamp()); var_dump($expected == $date2); var_dump(round($expected->getTimestamp(), 6) == round($date2->getTimestamp(), 6));
based on c54Dt
Output for 7.2.0 - 7.3.0rc3
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) bool(true) bool(true)
Output for 7.1.0 - 7.1.20
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) bool(false) bool(true)
Output for 7.0.0 - 7.0.20
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) Warning: DateTimeImmutable::modify(): Failed to parse time string (1 seconds 2 microseconds) at position 10 (2): Unexpected character in /in/MoV7D on line 10 bool(false) Fatal error: Uncaught Error: Call to a member function getTimestamp() on boolean in /in/MoV7D:12 Stack trace: #0 {main} thrown in /in/MoV7D on line 12
Process exited with code 255.
Output for hhvm-3.15.4
object(DateTimeImmutable)#1 (1) { ["data":"DateTimeImmutable":private]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } int(1440975724) Warning: DateTime::modify(): Failed to parse time string (1 seconds 2 microseconds) at position 10 (2): Unexpected character object(DateTimeImmutable)#5 (1) { ["data":"DateTimeImmutable":private]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2015-08-31 01:02:03.456788" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } int(1440975723) bool(false) bool(false)
Output for 5.6.0 - 5.6.30
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2015-08-31 01:02:04.456790" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } int(1440975724) Warning: DateTimeImmutable::modify(): Failed to parse time string (1 seconds 2 microseconds) at position 10 (2): Unexpected character in /in/MoV7D on line 10 bool(false) Fatal error: Call to a member function getTimestamp() on boolean in /in/MoV7D on line 12
Process exited with code 255.