From 9f35c11a2f8b196134404ccf2821f8931f069750 Mon Sep 17 00:00:00 2001 From: andrewrbe Date: Thu, 28 Dec 2017 15:06:09 +0200 Subject: [PATCH] Not all timezones have hour offset, so we can not just divide offset in seconds to 3600 Examples: Pacific/Chatham (UTC +12:45); Asia/Kathmandu (UTC +05:45) (#908) --- helpers/Timezone.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helpers/Timezone.php b/helpers/Timezone.php index 935940524..048c33e8d 100644 --- a/helpers/Timezone.php +++ b/helpers/Timezone.php @@ -31,10 +31,11 @@ public static function getAll() foreach ($timeZoneIdentifiers as $timeZone) { $date = new \DateTime('now', new \DateTimeZone($timeZone)); - $offset = $date->getOffset() / 60 / 60; + $offset = $date->getOffset(); + $tz = ($offset > 0 ? '+' : '-') . gmdate('H:i', abs($offset)); $timeZones[] = [ 'timezone' => $timeZone, - 'name' => "{$timeZone} (UTC " . ($offset > 0 ? '+' : '') . "{$offset})", + 'name' => "{$timeZone} (UTC {$tz})", 'offset' => $offset ]; }