public static function generateList($region = DateTimeZone::ALL)
    {
        $regions = array(
            DateTimeZone::AFRICA,
            DateTimeZone::AMERICA,
            DateTimeZone::ANTARCTICA,
            DateTimeZone::ASIA,
            DateTimeZone::ATLANTIC,
            DateTimeZone::AUSTRALIA,
            DateTimeZone::EUROPE,
            DateTimeZone::INDIAN,
            DateTimeZone::PACIFIC,
        );
        if ($region !== DateTimeZone::ALL && !in_array($region, $regions)) {
            $region = DateTimeZone::ALL;
        }
        $timezones = array();
        if ($region == DateTimeZone::ALL) {
            foreach ($regions as $r) {
                $timezones = array_merge($timezones, DateTimeZone::listIdentifiers($r));
            }
        } else {
            $timezones = DateTimeZone::listIdentifiers($region);
        }

        $timezone_offsets = array();
        foreach ($timezones as $timezone) {
            $tz = new DateTimeZone($timezone);
            $timezone_offsets[$timezone] = $tz->getOffset(new DateTime);
        }
        asort($timezone_offsets);

        $timezone_list = array();
        foreach ($timezone_offsets as $timezone => $offset) {
            $offset_prefix = $offset < 0 ? '-' : '+';
            $offset_formatted = gmdate('H:i', abs($offset));
            $pretty_offset = "UTC${offset_prefix}${offset_formatted}";
            $t = new DateTimeZone($timezone);
            $c = new DateTime(null, $t);
            $timezone_list[$timezone] = $pretty_offset . " - " . $timezone;
        }
        return $timezone_list;
    }
public static function generateList($region = DateTimeZone::ALL)
    {
        $regions = array(
            DateTimeZone::AFRICA,
            DateTimeZone::AMERICA,
            DateTimeZone::ANTARCTICA,
            DateTimeZone::ASIA,
            DateTimeZone::ATLANTIC,
            DateTimeZone::AUSTRALIA,
            DateTimeZone::EUROPE,
            DateTimeZone::INDIAN,
            DateTimeZone::PACIFIC,
        );
        if ($region !== DateTimeZone::ALL && !in_array($region, $regions)) {
            $region = DateTimeZone::ALL;
        }
        $timezones = array();
        if ($region == DateTimeZone::ALL) {
            foreach ($regions as $r) {
                $timezones = array_merge($timezones, DateTimeZone::listIdentifiers($r));
            }
        } else {
            $timezones = DateTimeZone::listIdentifiers($region);
        }

        $timezone_offsets = array();
        foreach ($timezones as $timezone) {
            $tz = new DateTimeZone($timezone);
            $timezone_offsets[$timezone] = $tz->getOffset(new DateTime);
        }
        asort($timezone_offsets);

        $timezone_list = array();
        foreach ($timezone_offsets as $timezone => $offset) {
            $offset_prefix = $offset < 0 ? '-' : '+';
            $offset_formatted = gmdate('H:i', abs($offset));
            $pretty_offset = "UTC${offset_prefix}${offset_formatted}";
            $t = new DateTimeZone($timezone);
            $c = new DateTime(null, $t);
            $timezone_list[$timezone] = $pretty_offset . " - " . $timezone;
        }
        return $timezone_list;
    }
public static function generateList ( $ region = DateTimeZone :: ALL ) { $ regions = array ( DateTimeZone :: AFRICA , DateTimeZone :: AMERICA , DateTimeZone :: ANTARCTICA , DateTimeZone :: ASIA , DateTimeZone :: ATLANTIC , DateTimeZone :: AUSTRALIA , DateTimeZone :: EUROPE , DateTimeZone :: INDIAN , DateTimeZone :: PACIFIC , ) ; if ( $ region !== DateTimeZone :: ALL && ! in_array ( $ region , $ regions ) ) { $ region = DateTimeZone :: ALL ; } $ timezones = array ( ) ; if ( $ region == DateTimeZone :: ALL ) { foreach ( $ regions as $ r ) { $ timezones = array_merge ( $ timezones , DateTimeZone :: listIdentifiers ( $ r ) ) ; } } else { $ timezones = DateTimeZone :: listIdentifiers ( $ region ) ; } $ timezone_offsets = array ( ) ; foreach ( $ timezones as $ timezone ) { $ tz = new DateTimeZone ( $ timezone ) ; $ timezone_offsets [ $ timezone ] = $ tz -> getOffset ( new DateTime ) ; } asort ( $ timezone_offsets ) ; $ timezone_list = array ( ) ; foreach ( $ timezone_offsets as $ timezone => $ offset ) { $ offset_prefix = $ offset < 0 ? '-' : '+' ; $ offset_formatted = gmdate ( 'H:i' , abs ( $ offset ) ) ; $ pretty_offset = "UTC${offset_prefix}${offset_formatted}" ; $ t = new DateTimeZone ( $ timezone ) ; $ c = new DateTime ( null , $ t ) ; $ timezone_list [ $ timezone ] = $ pretty_offset . " - " . $ timezone ; } return $ timezone_list ; }
Generate Time Zone List.
@param int $region
@return array
Generate Time Zone List .