Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

timezone_identifiers_list

(PHP 5 >= 5.1.0RC1)

timezone_identifiers_list -- Returns numerically index array with all timezone identifiers

Описание

array timezone_identifiers_list ( void )

array DateTimeZone::listIdentifiers ( void )

Возвращаемые значения

Returns array on success or FALSE on failure.

Примеры

Пример 1. A timezone_identifiers_list() example

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

Результатом выполнения данного примера будет что-то подобное:

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



add a note add a note User Contributed Notes
timezone_identifiers_list
spam1 at dyden dot de
04-Jul-2007 06:22
Hi!
Since many are going to use these timezones for saving their users' timezones, I wrote a little something that builds the select-field for this purpose and removes the "Others" that are not supposed to be used.
Note that <optgroup> is not widely supported and causes a bug in Opera 6.
I know this is easy to do, but you need to examine the timezones first (for example to remember that Istanbul is in the category for two continents - of course).

<select name="timezonechoice" size="10"><?php
function timezonechoice($selectedzone) {
   
$all = timezone_identifiers_list();
   
$i = 0;
    foreach(
$all AS $zone) {
       
$zone = explode('/',$zone);
       
$zonen[$i]['continent'] = $zone[0];
       
$zonen[$i]['city'] = $zone[1];
       
$i++;
        }
   
asort($zonen);
    foreach(
$zonen AS $zone) {
   
extract($zone);
        if(
$continent == 'Africa' OR $continent == 'America' OR $continent == 'Antarctica' OR $continent == 'Arctic' OR $continent == 'Asia' OR $continent == 'Atlantic' OR $continent == 'Australia' OR $continent == 'Europe' OR $continent == 'Indian' OR $continent == 'Pacific') {
            if(!isset(
$letztercontinent)) $structure .= '
<optgroup label="'
.$continent.'">'; // continent
           
elseif($letztercontinent!=$continent) $structure .= '</optgroup>
<optgroup label="'
.$continent.'">'; // continent
           
if($city!='') $structure .= "
<option "
.((($continent.'/'.$city)==$selectedzone)?'selected="selected "':'')." value=\"".($continent.'/'.$city)."\">".str_replace('_',' ',$city)."</option>"; //Timezone
           
else $structure .= "
<option "
.(($continent==$selectedzone)?'selected="selected "':'')." value=\"".$continent."\">".$continent."</option>"; //Timezone
           
$letztercontinent = $continent;
            }
        }
   
$structure .= '
</optgroup>'
;
    return
$structure;
    }
echo
timezonechoice('Europe/Berlin');
?></select>

Hope this saves someone some effort.

timezone_name_from_abbr> <timezone_abbreviations_list
Last updated: Sat, 27 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571