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"; echo timezone_version_get(), "\n";
Output for 7.0.20, 7.1.5 - 7.1.7
UTC -03:00 UTC +11:00 UTC +07:00 2017.2
Output for 7.1.0
UTC -03:00 UTC +11:00 UTC +07:00 2016.10
Output for 5.6.21, 7.0.5 - 7.0.6
UTC -03:00 UTC +08:00 UTC +07:00 2016.3
Output for 5.6.19, 7.0.4
UTC -03:00 UTC +08:00 UTC +07:00 2016.1
Output for 5.6.15 - 5.6.18, 7.0.0 - 7.0.3
UTC -03:00 UTC +08:00 UTC +07:00 2015.7
Output for 5.6.28
UTC -03:00 UTC +08:00 UTC +07:00 2016.8
Output for 5.6.20
UTC -03:00 UTC +08:00 UTC +07:00 2016.2
Output for 5.6.13 - 5.6.14
UTC -03:00 UTC +08:00 UTC +07:00 2015.6
Output for 5.5.27 - 5.5.35, 5.6.11 - 5.6.12
UTC -03:00 UTC +08:00 UTC +07:00 2015.5
Output for 5.5.25 - 5.5.26, 5.6.9 - 5.6.10
UTC -03:00 UTC +08:00 UTC +07:00 2015.4
Output for 5.5.24, 5.6.8
UTC -03:00 UTC +08:00 UTC +07:00 2015.2
Output for 5.6.7
UTC -03:00 UTC +08:00 UTC +07:00 2015.1
Output for 5.4.34 - 5.4.45
UTC -03:00 UTC +08:00 UTC +07:00 2014.8
Output for 5.4.31 - 5.4.32
UTC -03:00 UTC +08:00 UTC +07:00 2014.5
Output for 5.4.29 - 5.4.30
UTC -03:00 UTC +08:00 UTC +07:00 2014.3
Output for 5.4.28
UTC -03:00 UTC +08:00 UTC +07:00 2014.2
Output for 5.4.27
UTC -03:00 UTC +08:00 UTC +07:00 2014.1
Output for 5.4.25 - 5.4.26
UTC -03:00 UTC +08:00 UTC +07:00 2013.9
Output for 5.4.22 - 5.4.24
UTC -03:00 UTC +08:00 UTC +07:00 2013.8
Output for 5.4.21
UTC -03:00 UTC +08:00 UTC +07:00 2013.6
Output for 5.4.18 - 5.4.20
UTC -04:00 UTC +08:00 UTC +07:00 2013.4
Output for 5.3.25 - 5.3.29, 5.4.15 - 5.4.17
UTC -04:00 UTC +08:00 UTC +07:00 2013.3
Output for 5.3.24, 5.4.14
UTC -04:00 UTC +08:00 UTC +07:00 2013.2
Output for 5.3.20 - 5.3.23, 5.4.10 - 5.4.13
UTC -04:00 UTC +08:00 UTC +07:00 2012.10
Output for 5.3.19, 5.4.9
UTC -04:00 UTC +08:00 UTC +07:00 2012.8
Output for 5.3.11 - 5.3.18, 5.4.4 - 5.4.8
UTC -04:00 UTC +08:00 UTC +07:00 2012.3
Output for 5.4.1 - 5.4.3
UTC -04:00 UTC +08:00 UTC +07:00 2012.2
Output for 5.3.9 - 5.3.10, 5.4.0
UTC -04:00 UTC +08:00 UTC +07:00 2011.14
Output for 5.3.7 - 5.3.8
UTC -04:00 UTC +08:00 UTC +07:00 2011.8
Output for 5.3.6
UTC -04:00 UTC +08:00 UTC +07:00 2011.4
Output for 5.3.4 - 5.3.5
UTC -04:00 UTC +08:00 UTC +07:00 2010.15
Output for 5.3.3
UTC -04:00 UTC +08:00 UTC +07:00 2010.9
Output for 5.3.2
UTC -04:00 UTC +11:00 UTC +05:00 2010.3
Output for 5.3.1
UTC -04:00 UTC +11:00 UTC +05:00 2009.18
Output for 5.3.0
UTC -04:00 UTC +08:00 UTC +07:00 2009.10
Output for 5.2.10 - 5.2.11, 5.2.14 - 5.2.17
UTC -04:00 UTC +08:00 UTC +07:00 Fatal error: Call to undefined function timezone_version_get() in /in/ZHfTQ on line 25
Process exited with code 255.
Output for 5.2.12 - 5.2.13
UTC -04:00 UTC +11:00 UTC +05:00 Fatal error: Call to undefined function timezone_version_get() in /in/ZHfTQ on line 25
Process exited with code 255.
Output for 5.2.6 - 5.2.9
UTC -03:00 UTC +08:00 UTC +07:00 Fatal error: Call to undefined function timezone_version_get() in /in/ZHfTQ on line 25
Process exited with code 255.
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/ZHfTQ:5 Stack trace: #0 /in/ZHfTQ(5): DateTimeZone->__construct('America/Argenti...') #1 /in/ZHfTQ(21): getStandardOffsetFromUTC('America/Argenti...') #2 {main} thrown in /in/ZHfTQ 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/ZHfTQ 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/ZHfTQ on line 5
Process exited with code 255.
Output for 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/ZHfTQ on line 5

preferences:
48.11 ms | 516 KiB | 5 Q