Here's one that creates a multidimensional array sorted by offset and niceified name:
function timezones() {
$timezones = [];
foreach (timezone_identifiers_list() as $timezone) {
$datetime = new \DateTime('now', new DateTimeZone($timezone));
$timezones[] = [
'sort' => str_replace(':', '', $datetime->format('P')),
'offset' => $datetime->format('P'),
'name' => str_replace('_', ' ', implode(', ', explode('/', $timezone))),
'timezone' => $timezone,
];
}
usort($timezones, function($a, $b) {
return $a['sort'] - $b['sort'] ?: strcmp($a['name'], $b['name']);
});
return $timezones;
}
foreach (timezones() as $timezone) {
echo '(UTC '.$timezone['offset'].') '.$timezone['name'].'<br>';
}
Echos:
(UTC -11:00) Pacific, Midway
(UTC -11:00) Pacific, Niue
(UTC -11:00) Pacific, Pago Pago
(UTC -10:00) Pacific, Honolulu
(UTC -10:00) Pacific, Johnston
(UTC -10:00) Pacific, Rarotonga
(UTC -10:00) Pacific, Tahiti
(UTC -09:30) Pacific, Marquesas
(UTC -09:00) America, Adak
(UTC -09:00) Pacific, Gambier
(UTC -08:00) America, Anchorage
(UTC -08:00) America, Juneau
...