Skip to content

Commit

Permalink
Not all timezones have hour offset, so we can not just divide offset …
Browse files Browse the repository at this point in the history
…in seconds to 3600 Examples: Pacific/Chatham (UTC +12:45); Asia/Kathmandu (UTC +05:45) (#908)
  • Loading branch information
andrewrbe authored and thiagotalma committed Dec 28, 2017
1 parent 147ad06 commit 9f35c11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions helpers/Timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
Expand Down

0 comments on commit 9f35c11

Please sign in to comment.