3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function runTest($a) { print "Before: " . $a->getTimestamp() . "\n"; $b = $a->modify('+1 day'); print "Result after: " . $b->getTimestamp() . "\n"; print "Original after: " . $a->getTimestamp() . "\n"; } print "Immutable:\n"; runTest(new DateTimeImmutable('12/12/2012 12:12:12')); print "\n\nStandard:\n"; runTest(new DateTime('12/12/2012 12:12:12'));
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Immutable: Before: 1355310732 Result after: 1355397132 Original after: 1355310732 Standard: Before: 1355310732 Result after: 1355397132 Original after: 1355397132
Output for 5.0.0 - 5.4.45
Immutable: Fatal error: Class 'DateTimeImmutable' not found in /in/lNPjb on line 12
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Immutable: Fatal error: Cannot instantiate non-existent class: datetimeimmutable in /in/lNPjb on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Immutable: Fatal error: Cannot instantiate non-existent class: datetimeimmutable in /in/lNPjb on line 12