PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.20.2
Last Build: October 16, 2017 12:40pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
file
graph
html
mail
math
misc
mobile
script
string
system
time
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:


See Also

And a shot out to:

LinuxSimple - www.linuxsimple.com
PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site