3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $x = new DateTimeImmutable('2015-07-31'); $y = $x->modify('first day of -1 month'); var_dump($y); var_dump($y->setDate($y->format('Y'), $y->format('n'), 30));
Output for 5.6.19 - 5.6.28, 7.0.4 - 7.2.0
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-06-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-06-30 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.24 - 5.6.18, 7.0.0 - 7.0.3
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-06-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2015-06-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.18 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/fG0cf on line 3
Process exited with code 255.