note 84459 added to function.date-default-timezone-set

From: Date: Tue, 15 Jul 2008 08:46:56 +0000
Subject: note 84459 added to function.date-default-timezone-set
Groups: php.notes 
Request: Send a blank email to php-notes+get-141516@lists.php.net to get a copy of this message
If you want users to choose their own timezones, here's some code that gets all available timezones but only uses one city for each possible value: <?php $timezones = DateTimeZone::listAbbreviations(); $cities = array(); foreach( $timezones as $key => $zones ) { foreach( $zones as $id => $zone ) { /** * Only get timezones explicitely not part of "Others". * @see http://www.php.net/manual/en/timezones.others.php */ if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $zone['timezone_id'] ) ) $cities[$zone['timezone_id']][] = $key; } } // For each city, have a comma separated list of all possible timezones for that city. foreach( $cities as $key => $value ) $cities[$key] = join( ', ', $value); // Only keep one city (the first and also most important) for each set of possibilities. $cities = array_unique( $cities ); // Sort by area/city name. ksort( $cities ); ?> ---- Server IP: 83.137.20.135 Probable Submitter: 82.204.6.194 ---- Manual Page -- http://www.php.net/manual/en/function.date-default-timezone-set.php Edit -- https://master.php.net/note/edit/84459 Del: integrated -- https://master.php.net/note/delete/84459/integrated Del: useless -- https://master.php.net/note/delete/84459/useless Del: bad code -- https://master.php.net/note/delete/84459/bad+code Del: spam -- https://master.php.net/note/delete/84459/spam Del: non-english -- https://master.php.net/note/delete/84459/non-english Del: in docs -- https://master.php.net/note/delete/84459/in+docs Del: other reasons-- https://master.php.net/note/delete/84459 Reject -- https://master.php.net/note/reject/84459 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141516) next »