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 (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-06-24 (Yesterday) RSS 2.0 feedNot enough user ratingsTotal: 91 This week: 18All time: 8,745 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.

Innovation Award
PHP Programming Innovation award nominee
March 2017
Number 10
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: 25 packages by
Country: Hong Kong Hong Kong
Age: ???
All time rank: 7714 in Hong Kong Hong Kong
Week rank: 2 Up1 in Hong Kong Hong Kong Up
Innovation award
Innovation award
Nominee: 11x

Details

Time Zones

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

Usage

Generate HTML code for SELECT tag:

use peterkahl\timeZones\timeZones;

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:

use peterkahl\timeZones\timeZones;

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

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file timeZones.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:91
This week:18
All time:8,745
This week:39Up