note 89111 added to function.timezone-identifiers-list

From: Date: Sun, 22 Feb 2009 16:11:46 +0000
Subject: note 89111 added to function.timezone-identifiers-list
Groups: php.notes 
Request: Send a blank email to php-notes+get-150951@lists.php.net to get a copy of this message
A better code snippet to return useful timezone information that can be used in a drop menu, for example: <?php $zones = timezone_identifiers_list(); foreach ($zones as $zone) { $zone = explode('/', $zone); // 0 => Continent, 1 => City // Only use "friendly" continent names if ($zone[0] == 'Africa' || $zone[0] == 'America' || $zone[0] == 'Antarctica' || $zone[0] == 'Arctic' || $zone[0] == 'Asia' || $zone[0] == 'Atlantic' || $zone[0] == 'Australia' || $zone[0] == 'Europe' || $zone[0] == 'Indian' || $zone[0] == 'Pacific') { if (isset($zone[1]) != '') { $locations[$zone[0]][$zone[0]. '/' . $zone[1]] = str_replace('_', ' ', $zone[1]); // Creates array(DateTimeZone => 'Friendly name') } } } ?> The $locations array will contain a multi-dimensional array for each continent like Array ( [Africa] => Array ( [Africa/Abidjan] => Abidjan [Africa/Accra] => Accra [Africa/Addis_Ababa] => Addis Ababa [Africa/Algiers] => Algiers ... ) [America] => Array ( [America/Adak] => Adak [America/Anchorage] => Anchorage [America/Anguilla] => Anguilla ... ---- Server IP: 87.124.35.190 Probable Submitter: 87.194.31.182 ---- Manual Page -- http://www.php.net/manual/en/function.timezone-identifiers-list.php Edit -- https://master.php.net/note/edit/89111 Del: integrated -- https://master.php.net/note/delete/89111/integrated Del: useless -- https://master.php.net/note/delete/89111/useless Del: bad code -- https://master.php.net/note/delete/89111/bad+code Del: spam -- https://master.php.net/note/delete/89111/spam Del: non-english -- https://master.php.net/note/delete/89111/non-english Del: in docs -- https://master.php.net/note/delete/89111/in+docs Del: other reasons-- https://master.php.net/note/delete/89111 Reject -- https://master.php.net/note/reject/89111 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150951) next »