3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Berlin'); $dt = new DateTimeImmutable('2008-03-01T13:00:00Z'); var_dump($dt, $dt->getOffset(), $dt->modify('+6month'), $dt->modify('+6month')->getOffset()); var_dump(DateTimeImmutable::createFromFormat('Y-m-d\\TH:i:sT', '2008-03-01T13:00:00Z')); var_dump(DateTimeImmutable::createFromFormat('Y-m-d\\TH:i:sO', '2008-03-01T13:00:00Z')); var_dump(DateTimeImmutable::createFromFormat('Y-m-d\\TH:i:sP', '2008-03-01T13:00:00Z')); $dp = DatePeriod::createFromISO8601String('R1/2008-03-01T13:00:00Z/P1Y2M10DT2H30M'); foreach ($dp as $d) { var_dump($d); }
Output for 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } int(0) object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-09-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } int(0) object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } object(DateTimeImmutable)#6 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTimeImmutable)#8 (3) { ["date"]=> string(26) "2009-05-11 15:30:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" }
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } int(0) object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-09-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } int(0) object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2008-03-01 13:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } Fatal error: Uncaught Error: Call to undefined method DatePeriod::createFromISO8601String() in /in/u2fmJ:10 Stack trace: #0 {main} thrown in /in/u2fmJ on line 10
Process exited with code 255.

preferences:
89.76 ms | 410 KiB | 5 Q