/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function getTimezoneOptions() { $abbr = DateTimeZone::listAbbreviations(); foreach ($abbr as $section => $zones) { foreach ($zones as $zone) { if (!$zone['timezone_id']) { continue; } continue; } // ignore the plain GMT zones continue; } $minutes = ($offset - $hours) * 60; $minutes = $minutes == 0 ? '00' : $minutes; // ignore the weird ones continue; } $options[$zone['timezone_id']] = str_replace('_', ' ', $zone['timezone_id']) . " ($sign$hours:$minutes)"; } } return $options; } // example output: ( [Africa/Abidjan] => Africa/Abidjan (+0:00) [Africa/Accra] => Africa/Accra (+0:00) [Africa/Addis_Ababa] => Africa/Addis Ababa (+3:00) [Africa/Algiers] => Africa/Algiers (+2:00) [Africa/Asmara] => Africa/Asmara (+3:00) ... )