我正在按国家/地区名称显示时区列表。
在这里回答: Country to timezones in PHP/Zend Framework
我打算致电DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US')
按国家/地区列出所有时区。
有没有简单的方法可以在PHP(PHP 5.3)中获取ISO 3166-1兼容国家/地区代码列表及其相应名称?
答案 0 :(得分:4)
我刚刚从Riccardo Zorn提到的链接中编制了一个列表。
$countryCodes = array('AFGHANISTAN' => 'AF',
//'AKROTIRI' => '*',
'ALBANIA' => 'AL',
'ALGERIA' => 'DZ',
'AMERICAN SAMOA' => 'AS',
'ANDORRA' => 'AD',
'ANGOLA' => 'AO',
'ANGUILLA' => 'AI',
'ANTARCTICA' => 'AQ',
'ANTIGUA AND BARBUDA' => 'AG',
'ARGENTINA' => 'AR',
'ARMENIA' => 'AM',
'ARUBA' => 'AW',
//'ASHMORE AND CARTIER ISLANDS' => '*',
'AUSTRALIA' => 'AU',
'AUSTRIA' => 'AT',
'AZERBAIJAN' => 'AZ',
'BAHAMAS, THE' => 'BS',
'BAHRAIN' => 'BH',
//'BAKER ISLAND' => '*',
'BANGLADESH' => 'BD',
'BARBADOS' => 'BB',
//'BASSAS DA INDIA' => '*',
'BELARUS' => 'BY',
'BELGIUM' => 'BE',
'BELIZE' => 'BZ',
'BENIN' => 'BJ',
'BERMUDA' => 'BM',
'BHUTAN' => 'BT',
'BOLIVIA' => 'BO',
'BOSNIA AND HERZEGOVINA' => 'BA',
'BOTSWANA' => 'BW',
'BOUVET ISLAND' => 'BV',
'BRAZIL' => 'BR',
'BRITISH INDIAN OCEAN TERRITORY' => 'IO',
'BRUNEI' => 'BN',
'BULGARIA' => 'BG',
'BURKINA FASO' => 'BF',
'BURMA' => 'MM',
'BURUNDI' => 'BI',
'CAMBODIA' => 'KH',
'CAMEROON' => 'CM',
'CANADA' => 'CA',
'CAPE VERDE' => 'CV',
'CAYMAN ISLANDS' => 'KY',
'CENTRAL AFRICAN REPUBLIC' => 'CF',
'CHAD' => 'TD',
'CHILE' => 'CL',
'CHINA' => 'CN',
'CHRISTMAS ISLAND' => 'CX',
//'CLIPPERTON ISLAND' => '*',
'COCOS (KEELING) ISLANDS' => 'CC',
'COLOMBIA' => 'CO',
'COMOROS' => 'KM',
'CONGO (BRAZZAVILLE) ' => 'CG',
'CONGO (KINSHASA)' => 'CD',
'COOK ISLANDS' => 'CK',
//'CORAL SEA ISLANDS' => '*',
'COSTA RICA' => 'CR',
'CÔTE D’IVOIRE' => 'CI',
'CROATIA' => 'HR',
'CUBA' => 'CU',
'CURAÇAO' => 'CW',
'CYPRUS' => 'CY',
'CZECH REPUBLIC' => 'CZ',
'DENMARK' => 'DK',
//'DHEKELIA' => '*',
'DJIBOUTI' => 'DJ',
'DOMINICA' => 'DM',
'DOMINICAN REPUBLIC' => 'DO',
'ECUADOR' => 'EC',
'EGYPT' => 'EG',
'EL SALVADOR' => 'SV',
'EQUATORIAL GUINEA' => 'GQ',
'ERITREA' => 'ER',
'ESTONIA' => 'EE',
'ETHIOPIA' => 'ET',
//'ETOROFU, HABOMAI, KUNASHIRI, AND SHIKOTAN ISLANDS' => '*',
//'EUROPA ISLAND' => '*',
'FALKLAND ISLANDS (ISLAS MALVINAS)' => 'FK',
'FAROE ISLANDS' => 'FO',
'FIJI' => 'FJ',
'FINLAND' => 'FI',
'FRANCE' => 'FR',
'FRENCH GUIANA' => 'GF',
'FRENCH POLYNESIA' => 'PF',
'FRENCH SOUTHERN AND ANTARCTIC LANDS' => 'TF',
'GABON' => 'GA',
'GAMBIA, THE' => 'GM',
//'GAZA STRIP' => '*',
'GEORGIA' => 'GE',
'GERMANY' => 'DE',
'GHANA' => 'GH',
'GIBRALTAR' => 'GI',
//'GLORIOSO ISLANDS' => '*',
'GREECE' => 'GR',
'GREENLAND' => 'GL',
'GRENADA' => 'GD',
'GUADELOUPE' => 'GP',
'GUAM' => 'GU',
'GUATEMALA' => 'GT',
'GUERNSEY' => 'GG',
'GUINEA' => 'GN',
'GUINEA-BISSAU' => 'GW',
'GUYANA' => 'GY',
'HAITI' => 'HT',
'HEARD ISLAND AND MCDONALD ISLANDS' => 'HM',
'HONDURAS' => 'HN',
'HONG KONG' => 'HK',
//'HOWLAND ISLAND' => '*',
'HUNGARY' => 'HU',
'ICELAND' => 'IS',
'INDIA' => 'IN',
'INDONESIA' => 'ID',
'IRAN' => 'IR',
'IRAQ' => 'IQ',
'IRELAND' => 'IE',
'ISLE OF MAN' => 'IM',
'ISRAEL' => 'IL',
'ITALY' => 'IT',
'JAMAICA' => 'JM',
//'JAN MAYEN' => '*',
'JAPAN' => 'JP',
//'JARVIS ISLAND' => '*',
'JERSEY' => 'JE',
//'JOHNSTON ATOLL' => '*',
'JORDAN' => 'JO',
//'JUAN DE NOVA ISLAND' => '*',
'KAZAKHSTAN' => 'KZ',
'KENYA' => 'KE',
//'KINGMAN REEF' => '*',
'KIRIBATI' => 'KI',
'KOREA, NORTH' => 'KP',
'KOREA, SOUTH' => 'KR',
//'KOSOVO' => '*',
'KUWAIT' => 'KW',
'KYRGYZSTAN' => 'KG',
'LAOS' => 'LA',
'LATVIA' => 'LV',
'LEBANON' => 'LB',
'LESOTHO' => 'LS',
'LIBERIA' => 'LR',
'LIBYA' => 'LY',
'LIECHTENSTEIN' => 'LI',
'LITHUANIA' => 'LT',
'LUXEMBOURG' => 'LU',
'MACAU' => 'MO',
'MACEDONIA' => 'MK',
'MADAGASCAR' => 'MG',
'MALAWI' => 'MW',
'MALAYSIA' => 'MY',
'MALDIVES' => 'MV',
'MALI' => 'ML',
'MALTA' => 'MT',
'MARSHALL ISLANDS' => 'MH',
'MARTINIQUE' => 'MQ',
'MAURITANIA' => 'MR',
'MAURITIUS' => 'MU',
'MAYOTTE' => 'YT',
'MEXICO' => 'MX',
'MICRONESIA, FEDERATED STATES OF' => 'FM',
//'MIDWAY ISLANDS' => '*',
'MOLDOVA' => 'MD',
'MONACO' => 'MC',
'MONGOLIA' => 'MN',
'MONTENEGRO' => 'ME',
'MONTSERRAT' => 'MS',
'MOROCCO' => 'MA',
'MOZAMBIQUE' => 'MZ',
'NAMIBIA' => 'NA',
'NAURU' => 'NR',
//'NAVASSA ISLAND' => '*',
'NEPAL' => 'NP',
'NETHERLANDS' => 'NL',
'NEW CALEDONIA' => 'NC',
'NEW ZEALAND' => 'NZ',
'NICARAGUA' => 'NI',
'NIGER' => 'NE',
'NIGERIA' => 'NG',
'NIUE' => 'NU',
'NORFOLK ISLAND' => 'NF',
'NORTHERN MARIANA ISLANDS' => 'MP',
'NORWAY' => 'NO',
'OMAN' => 'OM',
'PAKISTAN' => 'PK',
'PALAU' => 'PW',
//'PALMYRA ATOLL' => '*',
'PANAMA' => 'PA',
'PAPUA NEW GUINEA' => 'PG',
//'PARACEL ISLANDS' => '*',
'PARAGUAY' => 'PY',
'PERU' => 'PE',
'PHILIPPINES' => 'PH',
'PITCAIRN ISLANDS' => 'PN',
'POLAND' => 'PL',
'PORTUGAL' => 'PT',
'PUERTO RICO' => 'PR',
'QATAR' => 'QA',
'REUNION' => 'RE',
'ROMANIA' => 'RO',
'RUSSIA' => 'RU',
'RWANDA' => 'RW',
'SAINT BARTHELEMY' => 'BL',
'SAINT HELENA, ASCENSION, AND TRISTAN DA CUNHA' => 'SH',
'SAINT KITTS AND NEVIS' => 'KN',
'SAINT LUCIA' => 'LC',
'SAINT MARTIN' => 'MF',
'SAINT PIERRE AND MIQUELON' => 'PM',
'SAINT VINCENT AND THE GRENADINES' => 'VC',
'SAMOA' => 'WS',
'SAN MARINO' => 'SM',
'SAO TOME AND PRINCIPE' => 'ST',
'SAUDI ARABIA' => 'SA',
'SENEGAL' => 'SN',
'SERBIA' => 'RS',
'SEYCHELLES' => 'SC',
'SIERRA LEONE' => 'SL',
'SINGAPORE' => 'SG',
'SINT MAARTEN' => 'SX',
'SLOVAKIA' => 'SK',
'SLOVENIA' => 'SI',
'SOLOMON ISLANDS' => 'SB',
'SOMALIA' => 'SO',
'SOUTH AFRICA' => 'ZA',
'SOUTH GEORGIA AND SOUTH SANDWICH ISLANDS' => 'GS',
'SOUTH SUDAN' => 'SS',
'SPAIN' => 'ES',
//'SPRATLY ISLANDS' => '*',
'SRI LANKA' => 'LK',
'SUDAN' => 'SD',
'SURINAME' => 'SR',
//'SVALBARD' => '*',
'SWAZILAND' => 'SZ',
'SWEDEN' => 'SE',
'SWITZERLAND' => 'CH',
'SYRIA' => 'SY',
'TAIWAN' => 'TW',
'TAJIKISTAN' => 'TJ',
'TANZANIA' => 'TZ',
'THAILAND' => 'TH',
'TIMOR-LESTE' => 'TL',
'TOGO' => 'TG',
'TOKELAU' => 'TK',
'TONGA' => 'TO',
'TRINIDAD AND TOBAGO' => 'TT',
//'TROMELIN ISLAND' => '*',
'TUNISIA' => 'TN',
'TURKEY' => 'TR',
'TURKMENISTAN' => 'TM',
'TURKS AND CAICOS ISLANDS' => 'TC',
'TUVALU' => 'TV',
'UGANDA' => 'UG',
'UKRAINE' => 'UA',
'UNITED ARAB EMIRATES' => 'AE',
'UNITED KINGDOM' => 'GB',
'UNITED STATES' => 'US',
'URUGUAY' => 'UY',
'UZBEKISTAN' => 'UZ',
'VANUATU' => 'VU',
'VATICAN CITY' => 'VA',
'VENEZUELA' => 'VE',
'VIETNAM' => 'VN',
'VIRGIN ISLANDS, BRITISH' => 'VG',
'VIRGIN ISLANDS, UNITED STATES ' => 'VI',
//'WAKE ISLAND' => '*',
'WALLIS AND FUTUNA' => 'WF',
//'WEST BANK' => '*',
'WESTERN SAHARA' => 'EH',
'YEMEN' => 'YE',
'ZAMBIA' => 'ZM',
'ZIMBABWE' => 'ZW');
public static $countryCodes = array(
'US' => 'United States',
'IN' => 'India',
'AF' => 'Afghanistan',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua And Barbuda',
'AR' => 'Argentina',
'AM' => 'Armenia',
'AW' => 'Aruba',
'AU' => 'Australia',
'AT' => 'Austria',
'AZ' => 'Azerbaijan',
'BS' => 'Bahamas, The',
'BH' => 'Bahrain',
'BD' => 'Bangladesh',
'BB' => 'Barbados',
'BY' => 'Belarus',
'BE' => 'Belgium',
'BZ' => 'Belize',
'BJ' => 'Benin',
'BM' => 'Bermuda',
'BT' => 'Bhutan',
'BO' => 'Bolivia',
'BA' => 'Bosnia And Herzegovina',
'BW' => 'Botswana',
'BV' => 'Bouvet Island',
'BR' => 'Brazil',
'IO' => 'British Indian Ocean Territory',
'BN' => 'Brunei',
'BG' => 'Bulgaria',
'BF' => 'Burkina Faso',
'MM' => 'Burma',
'BI' => 'Burundi',
'KH' => 'Cambodia',
'CM' => 'Cameroon',
'CA' => 'Canada',
'CV' => 'Cape Verde',
'KY' => 'Cayman Islands',
'CF' => 'Central African Republic',
'TD' => 'Chad',
'CL' => 'Chile',
'CN' => 'China',
'CX' => 'Christmas Island',
'CC' => 'Cocos (keeling) Islands',
'CO' => 'Colombia',
'KM' => 'Comoros',
'CG' => 'Congo (brazzaville) ',
'CD' => 'Congo (kinshasa)',
'CK' => 'Cook Islands',
'CR' => 'Costa Rica',
'CI' => 'CÔte D’ivoire',
'HR' => 'Croatia',
'CU' => 'Cuba',
'CW' => 'CuraÇao',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'DJ' => 'Djibouti',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'EC' => 'Ecuador',
'EG' => 'Egypt',
'SV' => 'El Salvador',
'GQ' => 'Equatorial Guinea',
'ER' => 'Eritrea',
'EE' => 'Estonia',
'ET' => 'Ethiopia',
'FK' => 'Falkland Islands (islas Malvinas)',
'FO' => 'Faroe Islands',
'FJ' => 'Fiji',
'FI' => 'Finland',
'FR' => 'France',
'GF' => 'French Guiana',
'PF' => 'French Polynesia',
'TF' => 'French Southern And Antarctic Lands',
'GA' => 'Gabon',
'GM' => 'Gambia, The',
'GE' => 'Georgia',
'DE' => 'Germany',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GR' => 'Greece',
'GL' => 'Greenland',
'GD' => 'Grenada',
'GP' => 'Guadeloupe',
'GU' => 'Guam',
'GT' => 'Guatemala',
'GG' => 'Guernsey',
'GN' => 'Guinea',
'GW' => 'Guinea-bissau',
'GY' => 'Guyana',
'HT' => 'Haiti',
'HM' => 'Heard Island And Mcdonald Islands',
'HN' => 'Honduras',
'HK' => 'Hong Kong',
'HU' => 'Hungary',
'IS' => 'Iceland',
//'IN' => 'India',
'ID' => 'Indonesia',
'IR' => 'Iran',
'IQ' => 'Iraq',
'IE' => 'Ireland',
'IM' => 'Isle Of Man',
'IL' => 'Israel',
'IT' => 'Italy',
'JM' => 'Jamaica',
'JP' => 'Japan',
'JE' => 'Jersey',
'JO' => 'Jordan',
'KZ' => 'Kazakhstan',
'KE' => 'Kenya',
'KI' => 'Kiribati',
'KP' => 'Korea, North',
'KR' => 'Korea, South',
'KW' => 'Kuwait',
'KG' => 'Kyrgyzstan',
'LA' => 'Laos',
'LV' => 'Latvia',
'LB' => 'Lebanon',
'LS' => 'Lesotho',
'LR' => 'Liberia',
'LY' => 'Libya',
'LI' => 'Liechtenstein',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MO' => 'Macau',
'MK' => 'Macedonia',
'MG' => 'Madagascar',
'MW' => 'Malawi',
'MY' => 'Malaysia',
'MV' => 'Maldives',
'ML' => 'Mali',
'MT' => 'Malta',
'MH' => 'Marshall Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MU' => 'Mauritius',
'YT' => 'Mayotte',
'MX' => 'Mexico',
'FM' => 'Micronesia, Federated States Of',
'MD' => 'Moldova',
'MC' => 'Monaco',
'MN' => 'Mongolia',
'ME' => 'Montenegro',
'MS' => 'Montserrat',
'MA' => 'Morocco',
'MZ' => 'Mozambique',
'NA' => 'Namibia',
'NR' => 'Nauru',
'NP' => 'Nepal',
'NL' => 'Netherlands',
'NC' => 'New Caledonia',
'NZ' => 'New Zealand',
'NI' => 'Nicaragua',
'NE' => 'Niger',
'NG' => 'Nigeria',
'NU' => 'Niue',
'NF' => 'Norfolk Island',
'MP' => 'Northern Mariana Islands',
'NO' => 'Norway',
'OM' => 'Oman',
'PK' => 'Pakistan',
'PW' => 'Palau',
'PA' => 'Panama',
'PG' => 'Papua New Guinea',
'PY' => 'Paraguay',
'PE' => 'Peru',
'PH' => 'Philippines',
'PN' => 'Pitcairn Islands',
'PL' => 'Poland',
'PT' => 'Portugal',
'PR' => 'Puerto Rico',
'QA' => 'Qatar',
'RE' => 'Reunion',
'RO' => 'Romania',
'RU' => 'Russia',
'RW' => 'Rwanda',
'BL' => 'Saint Barthelemy',
'SH' => 'Saint Helena, Ascension, And Tristan Da Cunha',
'KN' => 'Saint Kitts And Nevis',
'LC' => 'Saint Lucia',
'MF' => 'Saint Martin',
'PM' => 'Saint Pierre And Miquelon',
'VC' => 'Saint Vincent And The Grenadines',
'WS' => 'Samoa',
'SM' => 'San Marino',
'ST' => 'Sao Tome And Principe',
'SA' => 'Saudi Arabia',
'SN' => 'Senegal',
'RS' => 'Serbia',
'SC' => 'Seychelles',
'SL' => 'Sierra Leone',
'SG' => 'Singapore',
'SX' => 'Sint Maarten',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'SB' => 'Solomon Islands',
'SO' => 'Somalia',
'ZA' => 'South Africa',
'GS' => 'South Georgia And South Sandwich Islands',
'SS' => 'South Sudan',
'ES' => 'Spain',
'LK' => 'Sri Lanka',
'SD' => 'Sudan',
'SR' => 'Suriname',
'SZ' => 'Swaziland',
'SE' => 'Sweden',
'CH' => 'Switzerland',
'SY' => 'Syria',
'TW' => 'Taiwan',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania',
'TH' => 'Thailand',
'TL' => 'Timor-leste',
'TG' => 'Togo',
'TK' => 'Tokelau',
'TO' => 'Tonga',
'TT' => 'Trinidad And Tobago',
'TN' => 'Tunisia',
'TR' => 'Turkey',
'TM' => 'Turkmenistan',
'TC' => 'Turks And Caicos Islands',
'TV' => 'Tuvalu',
'UG' => 'Uganda',
'UA' => 'Ukraine',
'AE' => 'United Arab Emirates',
'GB' => 'United Kingdom',
//'US' => 'United States', //added at the top
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VU' => 'Vanuatu',
'VA' => 'Vatican City',
'VE' => 'Venezuela',
'VN' => 'Vietnam',
'VG' => 'Virgin Islands, British',
'VI' => 'Virgin Islands, United States ',
'WF' => 'Wallis And Futuna',
'EH' => 'Western Sahara',
'YE' => 'Yemen',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe');
可能对其他人有用
答案 1 :(得分:4)
您可以获取一个JSON文件,其中包含http://country.io/names.json名称的国家/地区代码,您可以使用该代码将国家/地区代码转换为名称:
// Either download the JSON in your code like this,
// or just paste the contents into your code
$country_names = json_decode(
file_get_contents("http://country.io/names.json")
, true);
function get_name($cc) {
return $country_names[$cc];
}
get_name("GB"); // => "United Kingdom"
答案 2 :(得分:3)
我现在已经维持https://github.com/thephpleague/iso3166很长一段时间了。没什么好看的,只是提供它所宣传的东西: - )
早期版本支持PHP 5.3,但我最近放弃了它,因为它已完全终止。
答案 3 :(得分:2)
查看我能找到的最广泛和最新的列表:
http earth-info.nima.mil/gns/html/gazetteers2.html (旧链接见下文)
他们提供xls下载,其中包含以下列:
FIPS 10-4 ISO 3166 digraph ISO 3166 trigraph ISO 3166 numeric TLD IOC SOVEREIGNTY
(查看xls文件中的第4张)
2016年更新:链接已失效,请尝试:http://geonames.nga.mil/gns/html/
答案 4 :(得分:0)
官方消息来源似乎很新,并且有不同的ISO 3166代码:
适合: