psTimeZones() List of Time Zones
Description:
This returns a list of times zones supported by the current php/system
Usage:
$ary = psTimeZones();
Example:
samples result:
[Europe/Monaco] => Array ( [desc] => Europe/Monaco (UTC +02:00) [offset] => 02.00 )
Code:
function psTimeZones() { $res = array(); $timestamp = time(); foreach(timezone_identifiers_list() as $key => $zone) { date_default_timezone_set($zone); $offset = date('P', $timestamp);
$zoneDesc = str_replace("_"," ",$zone); $res[$zone]['desc'] = "{$zoneDesc} (UTC {$offset})";
$offset = str_replace(":",".",$offset); $offset = str_replace("+","",$offset); $res[$zone]['offset'] = $offset; }
return $res; }
Changlelog:
|
|