note 89137 added to function.timezone-name-from-abbr

From: Date: Mon, 23 Feb 2009 22:03:53 +0000
Subject: note 89137 added to function.timezone-name-from-abbr
Groups: php.notes 
Request: Send a blank email to php-notes+get-151036@lists.php.net to get a copy of this message
I think this function is superior to the other two below. It first asks timezone_name_from_abbr for a name. If one is not found, we use the list to fill in the gap: <?php function getTZName($offset) { $isDst = date('I'); $offset *= 3600; $zone = timezone_name_from_abbr('', $offset, $isDst); if ($zone === false) { foreach (timezone_abbreviations_list() as $abbr) { foreach ($abbr as $city) { if ($city['timezone_id'] !== null && (bool)$city['dst'] == (bool)$isDst && $city['offset'] == $offset) { $zone = $city['timezone_id']; } } } } return $zone; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 66.138.198.129 ---- Manual Page -- http://www.php.net/manual/en/function.timezone-name-from-abbr.php Edit -- https://master.php.net/note/edit/89137 Del: integrated -- https://master.php.net/note/delete/89137/integrated Del: useless -- https://master.php.net/note/delete/89137/useless Del: bad code -- https://master.php.net/note/delete/89137/bad+code Del: spam -- https://master.php.net/note/delete/89137/spam Del: non-english -- https://master.php.net/note/delete/89137/non-english Del: in docs -- https://master.php.net/note/delete/89137/in+docs Del: other reasons-- https://master.php.net/note/delete/89137 Reject -- https://master.php.net/note/reject/89137 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151036) next »