Skip to content

Commit 9f35c11

Browse files
andrewrbethiagotalma
authored andcommitted
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)
1 parent 147ad06 commit 9f35c11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

helpers/Timezone.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ public static function getAll()
3131

3232
foreach ($timeZoneIdentifiers as $timeZone) {
3333
$date = new \DateTime('now', new \DateTimeZone($timeZone));
34-
$offset = $date->getOffset() / 60 / 60;
34+
$offset = $date->getOffset();
35+
$tz = ($offset > 0 ? '+' : '-') . gmdate('H:i', abs($offset));
3536
$timeZones[] = [
3637
'timezone' => $timeZone,
37-
'name' => "{$timeZone} (UTC " . ($offset > 0 ? '+' : '') . "{$offset})",
38+
'name' => "{$timeZone} (UTC {$tz})",
3839
'offset' => $offset
3940
];
4041
}

0 commit comments

Comments
 (0)