PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

timezone_name_from_abbr> <timezone_abbreviations_list
Last updated: Fri, 27 Jun 2008

view this page in

timezone_identifiers_list

(PHP 5 >= 5.1.0)

timezone_identifiers_list — Returns numerically index array with all timezone identifiers

Description

array timezone_identifiers_list ( void )
array DateTimeZone::listIdentifiers ( void )

Return Values

Returns array on success or FALSE on failure.

Examples

Example #1 A timezone_identifiers_list() example

<?php
$timezone_identifiers 
DateTimeZone::listIdentifiers();
for (
$i=0$i 5$i++) {
    echo 
"$timezone_identifiers[$i]\n";
}
?>

The above example will output something similar to:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmera



add a note add a note User Contributed Notes
timezone_identifiers_list
vats_tco at comcast dot net
19-Nov-2007 10:14
This is the updated code from below. This one has been debugged so it doesn't receive any warnings or errors like the code below will receive. Hope this helps.

<?php
function get_tz_options($selectedzone, $label, $desc = '')
{
  echo
'<div class="label"><label for="edited_user_timezone">'.$label.':</label></div>';
  echo
'<div class="input"><select name="edited_user_timezone">';
  function
timezonechoice($selectedzone) {
   
$all = timezone_identifiers_list();

   
$i = 0;
    foreach(
$all AS $zone) {
     
$zone = explode('/',$zone);
     
$zonen[$i]['continent'] = isset($zone[0]) ? $zone[0] : '';
     
$zonen[$i]['city'] = isset($zone[1]) ? $zone[1] : '';
     
$zonen[$i]['subcity'] = isset($zone[2]) ? $zone[2] : '';
     
$i++;
    }

   
asort($zonen);
   
$structure = '';
    foreach(
$zonen AS $zone) {
     
extract($zone);
      if(
$continent == 'Africa' || $continent == 'America' || $continent == 'Antarctica' || $continent == 'Arctic' || $continent == 'Asia' || $continent == 'Atlantic' || $continent == 'Australia' || $continent == 'Europe' || $continent == 'Indian' || $continent == 'Pacific') {
        if(!isset(
$selectcontinent)) {
         
$structure .= '<optgroup label="'.$continent.'">'; // continent
       
} elseif($selectcontinent != $continent) {
         
$structure .= '</optgroup><optgroup label="'.$continent.'">'; // continent
       
}

        if(isset(
$city) != ''){
          if (!empty(
$subcity) != ''){
           
$city = $city . '/'. $subcity;
          }
         
$structure .= "<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected "':'')." value=\"".($continent.'/'.$city)."\">".str_replace('_',' ',$city)."</option>"; //Timezone
       
} else {
          if (!empty(
$subcity) != ''){
           
$city = $city . '/'. $subcity;
          }
         
$structure .= "<option ".(($continent==$selectedzone)?'selected="selected "':'')." value=\"".$continent."\">".$continent."</option>"; //Timezone
       
}

       
$selectcontinent = $continent;
      }
    }
   
$structure .= '</optgroup>';
    return
$structure;
  }
  echo
timezonechoice($selectedzone);
  echo
'</select>';
  echo
'<span class="notes"> '.$desc.' </span></div>';
}
?>

timezone_name_from_abbr> <timezone_abbreviations_list
Last updated: Fri, 27 Jun 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites