<?php
function timezone_list()
{
static $timezones = null;
if ($timezones === null) {
$timezones = array();
$offsets = array();
$now = new DateTime();
foreach (DateTimeZone::listIdentifiers() as $timezone) {
$now->setTimezone(new DateTimeZone($timezone));
$offsets[] = $offset = $now->getOffset();
$timezones[$timezone] = '(GMT ' . ($offset ? sprintf('%+03d:%02d', intval($offset / 3600), abs(intval($offset % 3600 / 60))) : '')
. ') ' . str_replace(array("/", "_", "St "), array(", ", " ", "St. "), $timezone);
}
array_multisort($offsets, $timezones);
}
return $timezones;
}
print_r(timezone_list());
preferences:
34.47 ms | 402 KiB | 5 Q