3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getStandardOffsetFromUTC($timezone) { $timezone = new DateTimeZone($timezone); $transitions = array_slice($timezone->getTransitions(), -3); foreach (array_reverse($transitions) as $transition) { if ($transition['isdst'] == 1) // we are interested in standard offsets only { continue; } return sprintf('UTC %+03d:%02u', $transition['offset'] / 3600, abs($transition['offset']) % 3600 / 60); } return false; } echo getStandardOffsetFromUTC('America/Argentina/San_Luis') . "\n"; echo getStandardOffsetFromUTC('Antarctica/Casey') . "\n"; echo getStandardOffsetFromUTC('Antarctica/Davis') . "\n";
Output for 5.2.6 - 5.2.9, 5.4.21 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.6, 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.23, 7.4.0 - 7.4.11, 8.2.15 - 8.2.18, 8.3.2 - 8.3.6
UTC -03:00 UTC +08:00 UTC +07:00
Output for 7.0.20, 7.1.0 - 7.1.10, 7.2.0, 7.3.24 - 7.3.33, 7.4.12 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.14, 8.3.0 - 8.3.1
UTC -03:00 UTC +11:00 UTC +07:00
Output for 5.2.10 - 5.2.11, 5.2.14 - 5.2.17, 5.3.0, 5.3.3 - 5.3.29, 5.4.0 - 5.4.20
UTC -04:00 UTC +08:00 UTC +07:00
Output for 5.2.12 - 5.2.13, 5.3.1 - 5.3.2
UTC -04:00 UTC +11:00 UTC +05:00
Output for 5.2.0 - 5.2.5
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (America/Argentina/San_Luis)' in /in/V2YGi:5 Stack trace: #0 /in/V2YGi(5): DateTimeZone->__construct('America/Argenti...') #1 /in/V2YGi(21): getStandardOffsetFromUTC('America/Argenti...') #2 {main} thrown in /in/V2YGi on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/V2YGi on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/V2YGi on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/V2YGi on line 5

preferences:
264.11 ms | 401 KiB | 311 Q