3v4l.org

run code in 300+ PHP versions simultaneously
<?php $timezones = [ '+01:00', '+01:45', '+01:45:30' ]; $now = new DateTimeImmutable(); foreach ($timezones as $timezone) { $dtz = new DatetimeZone($timezone); echo $dtz->getName(), ', ', $dtz->getOffset($now), PHP_EOL; }
Output for 8.1.20 - 8.1.29, 8.2.7 - 8.2.23, 8.3.0 - 8.3.11
+01:00, 3600 +01:45, 6300 +01:45:30, 6330
Output for 8.1.7 - 8.1.19, 8.2.0 - 8.2.6
+01:00, 3600 +01:45, 6300 +01:45, 6330
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.6
+01:00, 3600 +01:45, 6300 Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (+01:45:30) in /in/fFpgU:11 Stack trace: #0 /in/fFpgU(11): DateTimeZone->__construct('+01:45:30') #1 {main} thrown in /in/fFpgU on line 11
Process exited with code 255.
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.9
+01:00, 3600 +01:45, 6300 +00:00, 0

preferences:
56.49 ms | 410 KiB | 5 Q