PHP Classes
elePHPant
Icontem

PHP TimeZones: Retrieve or validate world time zones

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-03-21 (6 days ago) RSS 2.0 feedNot enough user ratingsTotal: 74 This week: 27All time: 8,717 This week: 39Up
Version License PHP version Categories
timezones 0.1Custom (specified...5PHP 5, Time and Date, Geography
Description Author

This is a simple class that can retrieve or validate world time zones.

It can return associative array with the list of all timezones by name and the time offsets relative to UTC.

The class can also validate if a given timezone name is known.

  Performance   Level  
Name: Peter Kahl <contact>
Classes: 9 packages by
Country: Hong Kong Hong Kong
Age: ???
All time rank: 9594 in Hong Kong Hong Kong
Week rank: 8 Up1 in Hong Kong Hong Kong Up
Innovation award
Innovation award
Nominee: 4x

Details

Time Zones

Array of world time zones, sorted by time offset and alphabetically.

Usage

Generate HTML code for SELECT tag:

echo '<select>';
$zones = timeZones::getZones();
foreach ($zones as $code => $descr) {
  list($first, $city) = explode(') ', $descr);
  echo '<option value="'.$code.'">'.$first.') '.$city.'</option>';
}
echo '</select>';

Get city name of given time zone:

$zones = timeZones::getZones();
$arr   = explode(') ', $zones['Pacific/Rarotonga'])
$city  = end($arr); # Rarotonga, Cook Islands

  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file timezones.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:74
This week:27
All time:8,717
This week:39Up