PHP Classes

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 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 78 All time: 8,737 This week: 780Up
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.

Innovation Award
PHP Programming Innovation award nominee
March 2017
The world is divided into regions with different time zones, each with one time difference relative to the UTC time.

This class has the information of all the different time zones. It can validate time zones by name, as well return the time zones and the respective time offset.

Manuel Lemos
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 12 packages by
Country: Hong Kong Hong Kong
Age: ???
All time rank: 9014 in Hong Kong Hong Kong
Week rank: 2 Up1 in Hong Kong Hong Kong Up
Innovation award
Innovation award
Nominee: 6x


Time Zones

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


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 Doc. Documentation
Plain text file timezones.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,737
This week:780Up