3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(DateTimeImmutable::createFromMutable(new DateTime('midnight'))); var_dump(DateTimeImmutable::createFromMutable(new DateTimeImmutable('midnight')));
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Fatal error: Uncaught TypeError: DateTimeImmutable::createFromMutable(): Argument #1 ($object) must be of type DateTime, DateTimeImmutable given in /in/3IrR6:4 Stack trace: #0 /in/3IrR6(4): DateTimeImmutable::createFromMutable(Object(DateTimeImmutable)) #1 {main} thrown in /in/3IrR6 on line 4
Process exited with code 255.
Output for 8.0.13
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Fatal error: Uncaught TypeError: DateTimeImmutable::createFromMutable(): Argument #1 ($object) must be of type DateTime, DateTimeImmutable given in /in/3IrR6:4 Stack trace: #0 /in/3IrR6(4): DateTimeImmutable::createFromMutable(Object(DateTimeImmutable)) #1 {main} thrown in /in/3IrR6 on line 4
Process exited with code 255.
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for 7.3.32 - 7.3.33
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for 5.5.0 - 5.5.38
Fatal error: Call to undefined method DateTimeImmutable::createFromMutable() in /in/3IrR6 on line 3
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/3IrR6 on line 3
Process exited with code 255.

preferences:
269.03 ms | 401 KiB | 376 Q