PHP Salt


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

Version: 2.33.2
Last Build: December 29, 2023 20:28pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

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

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