note 106366 added to datetimezone.listidentifiers
| From: | neo22s at gmail dot com | Date: | Mon, 31 Oct 2011 13:50:52 +0000 |
| Subject: | note 106366 added to datetimezone.listidentifiers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184245@lists.php.net to get a copy of this message | ||
I normaly use this script to allow the user choose his timezone:
///timezones functions
function get_timezones()
{
if (method_exists('DateTimeZone','listIdentifiers'))
{
$timezones = array();
$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach( $timezone_identifiers as $value )
{
if ( preg_match(
'/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $value ) )
{
$ex=explode('/',$value);//obtain continent,city
$city = isset($ex[2])? $ex[1].' - '.$ex[2]:$ex[1];//in case a timezone has
more than one
$timezones[$ex[0]][$value] = $city;
}
}
return $timezones;
}
else//old php version
{
return FALSE;
}
}
function get_select_timezones($select_name='TIMEZONE',$selected=NULL)
{
$timezones = get_timezones();
$sel.='<select id="'.$select_name.'"
name="'.$select_name.'">';
foreach( $timezones as $continent=>$timezone )
{
$sel.= '<optgroup label="'.$continent.'">';
foreach( $timezone as $city=>$cityname )
{
if ($selected==$city)
{
$sel.= '<option selected=selected
value="'.$city.'">'.$cityname.'</option>';
}
else $sel.= '<option
value="'.$city.'">'.$cityname.'</option>';
}
$sel.= '</optgroup>';
}
$sel.='</select>';
return $sel;
}
----
Server IP: 69.147.83.197
Probable Submitter: 83.37.102.139
----
Manual Page -- http://www.php.net/manual/en/datetimezone.listidentifiers.php
Edit -- https://master.php.net/note/edit/106366
Del: integrated -- https://master.php.net/note/delete/106366/integrated
Del: useless -- https://master.php.net/note/delete/106366/useless
Del: bad code -- https://master.php.net/note/delete/106366/bad+code
Del: spam -- https://master.php.net/note/delete/106366/spam
Del: non-english -- https://master.php.net/note/delete/106366/non-english
Del: in docs -- https://master.php.net/note/delete/106366/in+docs
Del: other reasons-- https://master.php.net/note/delete/106366
Reject -- https://master.php.net/note/reject/106366
Search -- https://master.php.net/manage/user-notes.php