TimeZone select for PHP
Simple script that returns to us a list with possible TimeZones:
<select id="TIMEZONE" name="TIMEZONE"> <?php $timezone_identifiers = DateTimeZone::listIdentifiers(); foreach( $timezone_identifiers as $value ){ if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $value ) ){ echo "<option>$value</option>"; } } ?> </select>
Improved version:
<select id="TIMEZONE" name="TIMEZONE"> <?php $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 if ($continent!=$ex[0]){ if ($continent!="") echo '</optgroup>'; echo '<optgroup label="'.$ex[0].'">'; } $city=$ex[1]; $continent=$ex[0]; echo '<option value="'.$value.'">'.$city.'</option>'; } } ?> </optgroup> </select>
Be aware this will only work in PHP 5.2.0 or greater as they explain in the doc
Related Posts- Using Geonames from PHP
- Send email using Gmail and PHP
- How to create widgets for Open Classifieds 1.4.X
- Open Classifieds 1.4.3 Released
- Open Classifieds - Update to latest version 1.7.0.2
- Serums that work -- or not
- How to find out before going there if a restaurant is overpriced.
- Triathlon Tips Which Really Work
- 5 Steps to Improving your Triathlon Swim
Help sharing and Flatter me ;)
