Skip to content

Instantly share code, notes, and snippets.

@UmeshSingla
Last active December 18, 2015 19:08
Show Gist options
  • Save UmeshSingla/5830378 to your computer and use it in GitHub Desktop.
Save UmeshSingla/5830378 to your computer and use it in GitHub Desktop.
Country, State, Timezone List
<?php
function get_country_state_list($c = '',$only_country = FALSE) {
$countries = array(
'select_one' => __('Select one...', 'rtPanel'),
'AF' => __('Afghanistan', 'rtPanel'),
'AX' => __('&#197;land Islands', 'rtPanel'),
'AL' => __('Albania', 'rtPanel'),
'DZ' => __('Algeria', 'rtPanel'),
'AS' => __('American Samoa', 'rtPanel'),
'AD' => __('Andorra', 'rtPanel'),
'AO' => __('Angola', 'rtPanel'),
'AI' => __('Anguilla', 'rtPanel'),
'AQ' => __('Antarctica', 'rtPanel'),
'AG' => __('Antigua and Barbuda', 'rtPanel'),
'AR' => __('Argentina', 'rtPanel'),
'AM' => __('Armenia', 'rtPanel'),
'AW' => __('Aruba', 'rtPanel'),
'AU' => __('Australia', 'rtPanel'),
'AT' => __('Austria', 'rtPanel'),
'AZ' => __('Azerbaijan', 'rtPanel'),
'BS' => __('Bahamas', 'rtPanel'),
'BH' => __('Bahrain', 'rtPanel'),
'BD' => __('Bangladesh', 'rtPanel'),
'BB' => __('Barbados', 'rtPanel'),
'BY' => __('Belarus', 'rtPanel'),
'BE' => __('Belgium', 'rtPanel'),
'BZ' => __('Belize', 'rtPanel'),
'BJ' => __('Benin', 'rtPanel'),
'BM' => __('Bermuda', 'rtPanel'),
'BT' => __('Bhutan', 'rtPanel'),
'BO' => __('Bolivia', 'rtPanel'),
'BA' => __('Bosnia and Herzegovina', 'rtPanel'),
'BW' => __('Botswana', 'rtPanel'),
'BR' => __('Brazil', 'rtPanel'),
'IO' => __('British Indian Ocean Territory', 'rtPanel'),
'VG' => __('British Virgin Islands', 'rtPanel'),
'BN' => __('Brunei', 'rtPanel'),
'BG' => __('Bulgaria', 'rtPanel'),
'BF' => __('Burkina Faso', 'rtPanel'),
'BI' => __('Burundi', 'rtPanel'),
'KH' => __('Cambodia', 'rtPanel'),
'CM' => __('Cameroon', 'rtPanel'),
'CA' => __('Canada', 'rtPanel'),
'CV' => __('Cape Verde', 'rtPanel'),
'KY' => __('Cayman Islands', 'rtPanel'),
'CF' => __('Central African Republic', 'rtPanel'),
'TD' => __('Chad', 'rtPanel'),
'CL' => __('Chile', 'rtPanel'),
'CN' => __('China', 'rtPanel'),
'CX' => __('Christmas Island', 'rtPanel'),
'CC' => __('Cocos (Keeling) Islands', 'rtPanel'),
'CO' => __('Colombia', 'rtPanel'),
'KM' => __('Comoros', 'rtPanel'),
'CG' => __('Congo (Brazzaville)', 'rtPanel'),
'CD' => __('Congo (Kinshasa)', 'rtPanel'),
'CK' => __('Cook Islands', 'rtPanel'),
'CR' => __('Costa Rica', 'rtPanel'),
'HR' => __('Croatia', 'rtPanel'),
'CU' => __('Cuba', 'rtPanel'),
'CY' => __('Cyprus', 'rtPanel'),
'CZ' => __('Czech Republic', 'rtPanel'),
'DK' => __('Denmark', 'rtPanel'),
'DJ' => __('Djibouti', 'rtPanel'),
'DM' => __('Dominica', 'rtPanel'),
'DO' => __('Dominican Republic', 'rtPanel'),
'EC' => __('Ecuador', 'rtPanel'),
'EG' => __('Egypt', 'rtPanel'),
'SV' => __('El Salvador', 'rtPanel'),
'GQ' => __('Equatorial Guinea', 'rtPanel'),
'ER' => __('Eritrea', 'rtPanel'),
'EE' => __('Estonia', 'rtPanel'),
'ET' => __('Ethiopia', 'rtPanel'),
'FK' => __('Falkland Islands', 'rtPanel'),
'FO' => __('Faroe Islands', 'rtPanel'),
'FJ' => __('Fiji', 'rtPanel'),
'FI' => __('Finland', 'rtPanel'),
'FR' => __('France', 'rtPanel'),
'GF' => __('French Guiana', 'rtPanel'),
'PF' => __('French Polynesia', 'rtPanel'),
'TF' => __('French Southern Territories', 'rtPanel'),
'GA' => __('Gabon', 'rtPanel'),
'GM' => __('Gambia', 'rtPanel'),
'GE' => __('Georgia', 'rtPanel'),
'DE' => __('Germany', 'rtPanel'),
'GH' => __('Ghana', 'rtPanel'),
'GI' => __('Gibraltar', 'rtPanel'),
'GR' => __('Greece', 'rtPanel'),
'GL' => __('Greenland', 'rtPanel'),
'GD' => __('Grenada', 'rtPanel'),
'GP' => __('Guadeloupe', 'rtPanel'),
'GU' => __('Guam', 'rtPanel'),
'GT' => __('Guatemala', 'rtPanel'),
'GG' => __('Guernsey', 'rtPanel'),
'GN' => __('Guinea', 'rtPanel'),
'GW' => __('Guinea-Bissau', 'rtPanel'),
'GY' => __('Guyana', 'rtPanel'),
'HT' => __('Haiti', 'rtPanel'),
'HN' => __('Honduras', 'rtPanel'),
'HK' => __('Hong Kong', 'rtPanel'),
'HU' => __('Hungary', 'rtPanel'),
'IS' => __('Iceland', 'rtPanel'),
'IN' => __('India', 'rtPanel'),
'ID' => __('Indonesia', 'rtPanel'),
'IR' => __('Iran', 'rtPanel'),
'IQ' => __('Iraq', 'rtPanel'),
'IE' => __('Republic of Ireland', 'rtPanel'),
'IM' => __('Isle of Man', 'rtPanel'),
'IL' => __('Israel', 'rtPanel'),
'IT' => __('Italy', 'rtPanel'),
'CI' => __('Ivory Coast', 'rtPanel'),
'JM' => __('Jamaica', 'rtPanel'),
'JP' => __('Japan', 'rtPanel'),
'JE' => __('Jersey', 'rtPanel'),
'JO' => __('Jordan', 'rtPanel'),
'KZ' => __('Kazakhstan', 'rtPanel'),
'KE' => __('Kenya', 'rtPanel'),
'KI' => __('Kiribati', 'rtPanel'),
'KW' => __('Kuwait', 'rtPanel'),
'KG' => __('Kyrgyzstan', 'rtPanel'),
'LA' => __('Laos', 'rtPanel'),
'LV' => __('Latvia', 'rtPanel'),
'LB' => __('Lebanon', 'rtPanel'),
'LS' => __('Lesotho', 'rtPanel'),
'LR' => __('Liberia', 'rtPanel'),
'LY' => __('Libya', 'rtPanel'),
'LI' => __('Liechtenstein', 'rtPanel'),
'LT' => __('Lithuania', 'rtPanel'),
'LU' => __('Luxembourg', 'rtPanel'),
'MO' => __('Macao S.A.R., China', 'rtPanel'),
'MK' => __('Macedonia', 'rtPanel'),
'MG' => __('Madagascar', 'rtPanel'),
'MW' => __('Malawi', 'rtPanel'),
'MY' => __('Malaysia', 'rtPanel'),
'MV' => __('Maldives', 'rtPanel'),
'ML' => __('Mali', 'rtPanel'),
'MT' => __('Malta', 'rtPanel'),
'MH' => __('Marshall Islands', 'rtPanel'),
'MQ' => __('Martinique', 'rtPanel'),
'MR' => __('Mauritania', 'rtPanel'),
'MU' => __('Mauritius', 'rtPanel'),
'YT' => __('Mayotte', 'rtPanel'),
'MX' => __('Mexico', 'rtPanel'),
'FM' => __('Micronesia', 'rtPanel'),
'MD' => __('Moldova', 'rtPanel'),
'MC' => __('Monaco', 'rtPanel'),
'MN' => __('Mongolia', 'rtPanel'),
'ME' => __('Montenegro', 'rtPanel'),
'MS' => __('Montserrat', 'rtPanel'),
'MA' => __('Morocco', 'rtPanel'),
'MZ' => __('Mozambique', 'rtPanel'),
'MM' => __('Myanmar', 'rtPanel'),
'NA' => __('Namibia', 'rtPanel'),
'NR' => __('Nauru', 'rtPanel'),
'NP' => __('Nepal', 'rtPanel'),
'NL' => __('Netherlands', 'rtPanel'),
'AN' => __('Netherlands Antilles', 'rtPanel'),
'NC' => __('New Caledonia', 'rtPanel'),
'NZ' => __('New Zealand', 'rtPanel'),
'NI' => __('Nicaragua', 'rtPanel'),
'NE' => __('Niger', 'rtPanel'),
'NG' => __('Nigeria', 'rtPanel'),
'NU' => __('Niue', 'rtPanel'),
'NF' => __('Norfolk Island', 'rtPanel'),
'KP' => __('North Korea', 'rtPanel'),
'MP' => __('Northern Mariana Islands', 'rtPanel'),
'NO' => __('Norway', 'rtPanel'),
'OM' => __('Oman', 'rtPanel'),
'PK' => __('Pakistan', 'rtPanel'),
'PW' => __('Palau', 'rtPanel'),
'PS' => __('Palestinian Territory', 'rtPanel'),
'PA' => __('Panama', 'rtPanel'),
'PG' => __('Papua New Guinea', 'rtPanel'),
'PY' => __('Paraguay', 'rtPanel'),
'PE' => __('Peru', 'rtPanel'),
'PH' => __('Philippines', 'rtPanel'),
'PN' => __('Pitcairn', 'rtPanel'),
'PL' => __('Poland', 'rtPanel'),
'PT' => __('Portugal', 'rtPanel'),
'PR' => __('Puerto Rico', 'rtPanel'),
'QA' => __('Qatar', 'rtPanel'),
'RE' => __('Reunion', 'rtPanel'),
'RO' => __('Romania', 'rtPanel'),
'RU' => __('Russia', 'rtPanel'),
'RW' => __('Rwanda', 'rtPanel'),
'BL' => __('Saint Barth&eacute;lemy', 'rtPanel'),
'SH' => __('Saint Helena', 'rtPanel'),
'KN' => __('Saint Kitts and Nevis', 'rtPanel'),
'LC' => __('Saint Lucia', 'rtPanel'),
'MF' => __('Saint Martin (French part)', 'rtPanel'),
'PM' => __('Saint Pierre and Miquelon', 'rtPanel'),
'VC' => __('Saint Vincent and the Grenadines', 'rtPanel'),
'WS' => __('Samoa', 'rtPanel'),
'SM' => __('San Marino', 'rtPanel'),
'ST' => __('S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'rtPanel'),
'SA' => __('Saudi Arabia', 'rtPanel'),
'SN' => __('Senegal', 'rtPanel'),
'RS' => __('Serbia', 'rtPanel'),
'SC' => __('Seychelles', 'rtPanel'),
'SL' => __('Sierra Leone', 'rtPanel'),
'SG' => __('Singapore', 'rtPanel'),
'SK' => __('Slovakia', 'rtPanel'),
'SI' => __('Slovenia', 'rtPanel'),
'SB' => __('Solomon Islands', 'rtPanel'),
'SO' => __('Somalia', 'rtPanel'),
'ZA' => __('South Africa', 'rtPanel'),
'GS' => __('South Georgia/Sandwich Islands', 'rtPanel'),
'KR' => __('South Korea', 'rtPanel'),
'ES' => __('Spain', 'rtPanel'),
'LK' => __('Sri Lanka', 'rtPanel'),
'SD' => __('Sudan', 'rtPanel'),
'SR' => __('Suriname', 'rtPanel'),
'SJ' => __('Svalbard and Jan Mayen', 'rtPanel'),
'SZ' => __('Swaziland', 'rtPanel'),
'SE' => __('Sweden', 'rtPanel'),
'CH' => __('Switzerland', 'rtPanel'),
'SY' => __('Syria', 'rtPanel'),
'TW' => __('Taiwan', 'rtPanel'),
'TJ' => __('Tajikistan', 'rtPanel'),
'TZ' => __('Tanzania', 'rtPanel'),
'TH' => __('Thailand', 'rtPanel'),
'TL' => __('Timor-Leste', 'rtPanel'),
'TG' => __('Togo', 'rtPanel'),
'TK' => __('Tokelau', 'rtPanel'),
'TO' => __('Tonga', 'rtPanel'),
'TT' => __('Trinidad and Tobago', 'rtPanel'),
'TN' => __('Tunisia', 'rtPanel'),
'TR' => __('Turkey', 'rtPanel'),
'TM' => __('Turkmenistan', 'rtPanel'),
'TC' => __('Turks and Caicos Islands', 'rtPanel'),
'TV' => __('Tuvalu', 'rtPanel'),
'VI' => __('U.S. Virgin Islands', 'rtPanel'),
'UM' => __('US Minor Outlying Islands', 'rtPanel'),
'UG' => __('Uganda', 'rtPanel'),
'UA' => __('Ukraine', 'rtPanel'),
'AE' => __('United Arab Emirates', 'rtPanel'),
'GB' => __('United Kingdom', 'rtPanel'),
'US' => __('United States', 'rtPanel'),
'UY' => __('Uruguay', 'rtPanel'),
'UZ' => __('Uzbekistan', 'rtPanel'),
'VU' => __('Vanuatu', 'rtPanel'),
'VA' => __('Vatican', 'rtPanel'),
'VE' => __('Venezuela', 'rtPanel'),
'VN' => __('Vietnam', 'rtPanel'),
'WF' => __('Wallis and Futuna', 'rtPanel'),
'EH' => __('Western Sahara', 'rtPanel'),
'YE' => __('Yemen', 'rtPanel'),
'ZM' => __('Zambia', 'rtPanel'),
'ZW' => __('Zimbabwe', 'rtPanel')
);
// States set to array() are blank i.e. the country has no use for the state field.
$states = array('AU', 'BR', 'CA', 'CN', 'HK', 'HU', 'HZ', 'ID', 'IN', 'MY', 'NZ', 'TH', 'US', 'ZA');
$states['AU'] = array(
'ACT' => __( 'Australian Capital Territory', 'rtPanel' ),
'NSW' => __( 'New South Wales', 'rtPanel' ),
'NT' => __( 'Northern Territory', 'rtPanel' ),
'QLD' => __( 'Queensland', 'rtPanel' ),
'SA' => __( 'South Australia', 'rtPanel' ),
'TAS' => __( 'Tasmania', 'rtPanel' ),
'VIC' => __( 'Victoria', 'rtPanel' ),
'WA' => __( 'Western Australia', 'rtPanel' )
);
$states['BR'] = array(
'AC' => __( 'Acre', 'rtPanel' ),
'AL' => __( 'Alagoas', 'rtPanel' ),
'AP' => __( 'Amap&aacute;', 'rtPanel' ),
'AM' => __( 'Amazonas', 'rtPanel' ),
'BA' => __( 'Bahia', 'rtPanel' ),
'CE' => __( 'Cear&aacute;', 'rtPanel' ),
'DF' => __( 'Distrito Federal', 'rtPanel' ),
'ES' => __( 'Esp&iacute;rito Santo', 'rtPanel' ),
'GO' => __( 'Goi&aacute;s', 'rtPanel' ),
'MA' => __( 'Maranh&atilde;o', 'rtPanel' ),
'MT' => __( 'Mato Grosso', 'rtPanel' ),
'MS' => __( 'Mato Grosso do Sul', 'rtPanel' ),
'MG' => __( 'Minas Gerais', 'rtPanel' ),
'PA' => __( 'Par&aacute;', 'rtPanel' ),
'PB' => __( 'Para&iacute;ba', 'rtPanel' ),
'PR' => __( 'Paran&aacute;', 'rtPanel' ),
'PE' => __( 'Pernambuco', 'rtPanel' ),
'PI' => __( 'Piau&iacute;', 'rtPanel' ),
'RJ' => __( 'Rio de Janeiro', 'rtPanel' ),
'RN' => __( 'Rio Grande do Norte', 'rtPanel' ),
'RS' => __( 'Rio Grande do Sul', 'rtPanel' ),
'RO' => __( 'Rond&ocirc;nia', 'rtPanel' ),
'RR' => __( 'Roraima', 'rtPanel' ),
'SC' => __( 'Santa Catarina', 'rtPanel' ),
'SP' => __( 'S&atilde;o Paulo', 'rtPanel' ),
'SE' => __( 'Sergipe', 'rtPanel' ),
'TO' => __( 'Tocantins', 'rtPanel' )
);
$states['CA'] = array(
'AB' => __( 'Alberta', 'rtPanel' ),
'BC' => __( 'British Columbia', 'rtPanel' ),
'MB' => __( 'Manitoba', 'rtPanel' ),
'NB' => __( 'New Brunswick', 'rtPanel' ),
'NF' => __( 'Newfoundland', 'rtPanel' ),
'NT' => __( 'Northwest Territories', 'rtPanel' ),
'NS' => __( 'Nova Scotia', 'rtPanel' ),
'NU' => __( 'Nunavut', 'rtPanel' ),
'ON' => __( 'Ontario', 'rtPanel' ),
'PE' => __( 'Prince Edward Island', 'rtPanel' ),
'QC' => __( 'Quebec', 'rtPanel' ),
'SK' => __( 'Saskatchewan', 'rtPanel' ),
'YT' => __( 'Yukon Territory', 'rtPanel' )
);
$states['CN'] = array(
'CN1' => __( 'Yunnan / &#20113;&#21335;', 'rtPanel' ),
'CN2' => __( 'Beijing / &#21271;&#20140;', 'rtPanel' ),
'CN3' => __( 'Tianjin / &#22825;&#27941;', 'rtPanel' ),
'CN4' => __( 'Hebei / &#27827;&#21271;', 'rtPanel' ),
'CN5' => __( 'Shanxi / &#23665;&#35199;', 'rtPanel' ),
'CN6' => __( 'Inner Mongolia / &#20839;&#33945;&#21476;', 'rtPanel' ),
'CN7' => __( 'Liaoning / &#36797;&#23425;', 'rtPanel' ),
'CN8' => __( 'Jilin / &#21513;&#26519;', 'rtPanel' ),
'CN9' => __( 'Heilongjiang / &#40657;&#40857;&#27743;', 'rtPanel' ),
'CN10' => __( 'Shanghai / &#19978;&#28023;', 'rtPanel' ),
'CN11' => __( 'Jiangsu / &#27743;&#33487;', 'rtPanel' ),
'CN12' => __( 'Zhejiang / &#27993;&#27743;', 'rtPanel' ),
'CN13' => __( 'Anhui / &#23433;&#24509;', 'rtPanel' ),
'CN14' => __( 'Fujian / &#31119;&#24314;', 'rtPanel' ),
'CN15' => __( 'Jiangxi / &#27743;&#35199;', 'rtPanel' ),
'CN16' => __( 'Shandong / &#23665;&#19996;', 'rtPanel' ),
'CN17' => __( 'Henan / &#27827;&#21335;', 'rtPanel' ),
'CN18' => __( 'Hubei / &#28246;&#21271;', 'rtPanel' ),
'CN19' => __( 'Hunan / &#28246;&#21335;', 'rtPanel' ),
'CN20' => __( 'Guangdong / &#24191;&#19996;', 'rtPanel' ),
'CN21' => __( 'Guangxi Zhuang / &#24191;&#35199;&#22766;&#26063;', 'rtPanel' ),
'CN22' => __( 'Hainan / &#28023;&#21335;', 'rtPanel' ),
'CN23' => __( 'Chongqing / &#37325;&#24198;', 'rtPanel' ),
'CN24' => __( 'Sichuan / &#22235;&#24029;', 'rtPanel' ),
'CN25' => __( 'Guizhou / &#36149;&#24030;', 'rtPanel' ),
'CN26' => __( 'Shaanxi / &#38485;&#35199;', 'rtPanel' ),
'CN27' => __( 'Gansu / &#29976;&#32899;', 'rtPanel' ),
'CN28' => __( 'Qinghai / &#38738;&#28023;', 'rtPanel' ),
'CN29' => __( 'Ningxia Hui / &#23425;&#22799;', 'rtPanel' ),
'CN30' => __( 'Macau / &#28595;&#38376;', 'rtPanel' ),
'CN31' => __( 'Tibet / &#35199;&#34255;', 'rtPanel' ),
'CN32' => __( 'Xinjiang / &#26032;&#30086;', 'rtPanel' )
);
$states['HK'] = array(
'HONG KONG' => __( 'Hong Kong Island', 'rtPanel' ),
'KOWLOON' => __( 'Kowloon', 'rtPanel' ),
'NEW TERRITORIES' => __( 'New Territories', 'rtPanel' )
);
$states['HU'] = array(
'BK' => __( 'Bács-Kiskun', 'rtPanel' ),
'BE' => __( 'Békés', 'rtPanel' ),
'BA' => __( 'Baranya', 'rtPanel' ),
'BZ' => __( 'Borsod-Abaúj-Zemplén', 'rtPanel' ),
'BU' => __( 'Budapest', 'rtPanel' ),
'CS' => __( 'Csongrád', 'rtPanel' ),
'FE' => __( 'Fejér', 'rtPanel' ),
'GS' => __( 'Győr-Moson-Sopron', 'rtPanel' ),
'HB' => __( 'Hajdú-Bihar', 'rtPanel' ),
'HE' => __( 'Heves', 'rtPanel' ),
'JN' => __( 'Jász-Nagykun-Szolnok', 'rtPanel' ),
'KE' => __( 'Komárom-Esztergom', 'rtPanel' ),
'NO' => __( 'Nógrád', 'rtPanel' ),
'PE' => __( 'Pest', 'rtPanel' ),
'SO' => __( 'Somogy', 'rtPanel' ),
'SZ' => __( 'Szabolcs-Szatmár-Bereg', 'rtPanel' ),
'TO' => __( 'Tolna', 'rtPanel' ),
'VA' => __( 'Vas', 'rtPanel' ),
'VE' => __( 'Veszprém', 'rtPanel' ),
'ZA' => __( 'Zala', 'rtPanel' )
);
$states['HZ'] = array(
'AK' => __( 'Auckland', 'rtPanel' ),
'BP' => __( 'Bay of Plenty', 'rtPanel' ),
'CT' => __( 'Canterbury', 'rtPanel' ),
'HB' => __( 'Hawke&rsquo;s Bay', 'rtPanel' ),
'MW' => __( 'Manawatu-Wanganui', 'rtPanel' ),
'MB' => __( 'Marlborough', 'rtPanel' ),
'NS' => __( 'Nelson', 'rtPanel' ),
'NL' => __( 'Northland', 'rtPanel' ),
'OT' => __( 'Otago', 'rtPanel' ),
'SL' => __( 'Southland', 'rtPanel' ),
'TK' => __( 'Taranaki', 'rtPanel' ),
'TM' => __( 'Tasman', 'rtPanel' ),
'WA' => __( 'Waikato', 'rtPanel' ),
'WE' => __( 'Wellington', 'rtPanel' ),
'WC' => __( 'West Coast', 'rtPanel' )
);
$states['ID'] = array(
'AC' => __( 'Daerah Istimewa Aceh', 'rtPanel' ),
'SU' => __( 'Sumatera Utara', 'rtPanel' ),
'SB' => __( 'Sumatera Barat', 'rtPanel' ),
'RI' => __( 'Riau', 'rtPanel' ),
'KR' => __( 'Kepulauan Riau', 'rtPanel' ),
'JA' => __( 'Jambi', 'rtPanel' ),
'SS' => __( 'Sumatera Selatan', 'rtPanel' ),
'BB' => __( 'Bangka Belitung', 'rtPanel' ),
'BE' => __( 'Bengkulu', 'rtPanel' ),
'LA' => __( 'Lampung', 'rtPanel' ),
'JK' => __( 'DKI Jakarta', 'rtPanel' ),
'JB' => __( 'Jawa Barat', 'rtPanel' ),
'BT' => __( 'Banten', 'rtPanel' ),
'JT' => __( 'Jawa Tengah', 'rtPanel' ),
'JI' => __( 'Jawa Timur', 'rtPanel' ),
'YO' => __( 'Daerah Istimewa Yogyakarta', 'rtPanel' ),
'BA' => __( 'Bali', 'rtPanel' ),
'NB' => __( 'Nusa Tenggara Barat', 'rtPanel' ),
'NT' => __( 'Nusa Tenggara Timur', 'rtPanel' ),
'KB' => __( 'Kalimantan Barat', 'rtPanel' ),
'KT' => __( 'Kalimantan Tengah', 'rtPanel' ),
'KI' => __( 'Kalimantan Timur', 'rtPanel' ),
'KS' => __( 'Kalimantan Selatan', 'rtPanel' ),
'KU' => __( 'Kalimantan Utara', 'rtPanel' ),
'SA' => __( 'Sulawesi Utara', 'rtPanel' ),
'ST' => __( 'Sulawesi Tengah', 'rtPanel' ),
'SG' => __( 'Sulawesi Tenggara', 'rtPanel' ),
'SR' => __( 'Sulawesi Barat', 'rtPanel' ),
'SN' => __( 'Sulawesi Selatan', 'rtPanel' ),
'GO' => __( 'Gorontalo', 'rtPanel' ),
'MA' => __( 'Maluku', 'rtPanel' ),
'MU' => __( 'Maluku Utara', 'rtPanel' ),
'PA' => __( 'Papua', 'rtPanel' ),
'PB' => __( 'Papua Barat', 'rtPanel' )
);
$states['IN'] = array(
'AP' => __( 'Andra Pradesh', 'rtPanel' ),
'AR' => __( 'Arunachal Pradesh', 'rtPanel' ),
'AS' => __( 'Assam', 'rtPanel' ),
'BR' => __( 'Bihar', 'rtPanel' ),
'CT' => __( 'Chhattisgarh', 'rtPanel' ),
'GA' => __( 'Goa', 'rtPanel' ),
'GJ' => __( 'Gujarat', 'rtPanel' ),
'HR' => __( 'Haryana', 'rtPanel' ),
'HP' => __( 'Himachal Pradesh', 'rtPanel' ),
'JK' => __( 'Jammu and Kashmir', 'rtPanel' ),
'JH' => __( 'Jharkhand', 'rtPanel' ),
'KA' => __( 'Karnataka', 'rtPanel' ),
'KL' => __( 'Kerala', 'rtPanel' ),
'MP' => __( 'Madhya Pradesh', 'rtPanel' ),
'MH' => __( 'Maharashtra', 'rtPanel' ),
'MN' => __( 'Manipur', 'rtPanel' ),
'ML' => __( 'Meghalaya', 'rtPanel' ),
'MZ' => __( 'Mizoram', 'rtPanel' ),
'NL' => __( 'Nagaland', 'rtPanel' ),
'OR' => __( 'Orissa', 'rtPanel' ),
'PB' => __( 'Punjab', 'rtPanel' ),
'RJ' => __( 'Rajasthan', 'rtPanel' ),
'SK' => __( 'Sikkim', 'rtPanel' ),
'TN' => __( 'Tamil Nadu', 'rtPanel' ),
'TR' => __( 'Tripura', 'rtPanel' ),
'UT' => __( 'Uttaranchal', 'rtPanel' ),
'UP' => __( 'Uttar Pradesh', 'rtPanel' ),
'WB' => __( 'West Bengal', 'rtPanel' ),
'AN' => __( 'Andaman and Nicobar Islands', 'rtPanel' ),
'CH' => __( 'Chandigarh', 'rtPanel' ),
'DN' => __( 'Dadar and Nagar Haveli', 'rtPanel' ),
'DD' => __( 'Daman and Diu', 'rtPanel' ),
'DL' => __( 'Delhi', 'rtPanel' ),
'LD' => __( 'Lakshadeep', 'rtPanel' ),
'PY' => __( 'Pondicherry (Puducherry)', 'rtPanel' )
);
$states['MY'] = array(
'JHR' => __( 'Johor', 'rtPanel' ),
'KDH' => __( 'Kedah', 'rtPanel' ),
'KTN' => __( 'Kelantan', 'rtPanel' ),
'MLK' => __( 'Melaka', 'rtPanel' ),
'NSN' => __( 'Negeri Sembilan', 'rtPanel' ),
'PHG' => __( 'Pahang', 'rtPanel' ),
'PRK' => __( 'Perak', 'rtPanel' ),
'PLS' => __( 'Perlis', 'rtPanel' ),
'PNG' => __( 'Pulau Pinang', 'rtPanel' ),
'SBH' => __( 'Sabah', 'rtPanel' ),
'SWK' => __( 'Sarawak', 'rtPanel' ),
'SGR' => __( 'Selangor', 'rtPanel' ),
'TRG' => __( 'Terengganu', 'rtPanel' ),
'KUL' => __( 'W.P. Kuala Lumpur', 'rtPanel' ),
'LBN' => __( 'W.P. Labuan', 'rtPanel' ),
'PJY' => __( 'W.P. Putrajaya', 'rtPanel' )
);
$states['NZ'] = array(
'NL' => __( 'Northland', 'rtPanel' ),
'AK' => __( 'Auckland', 'rtPanel' ),
'WA' => __( 'Waikato', 'rtPanel' ),
'BP' => __( 'Bay of Plenty', 'rtPanel' ),
'TK' => __( 'Taranaki', 'rtPanel' ),
'HB' => __( 'Hawke&rsquo;s Bay', 'rtPanel' ),
'MW' => __( 'Manawatu-Wanganui', 'rtPanel' ),
'WE' => __( 'Wellington', 'rtPanel' ),
'NS' => __( 'Nelson', 'rtPanel' ),
'MB' => __( 'Marlborough', 'rtPanel' ),
'TM' => __( 'Tasman', 'rtPanel' ),
'WC' => __( 'West Coast', 'rtPanel' ),
'CT' => __( 'Canterbury', 'rtPanel' ),
'OT' => __( 'Otago', 'rtPanel' ),
'SL' => __( 'Southland', 'rtPanel')
);
$states['TH'] = array(
'TH-37' => __( 'Amnat Charoen (&#3629;&#3635;&#3609;&#3634;&#3592;&#3648;&#3592;&#3619;&#3636;&#3597;)', 'rtPanel' ),
'TH-15' => __( 'Ang Thong (&#3629;&#3656;&#3634;&#3591;&#3607;&#3629;&#3591;)', 'rtPanel' ),
'TH-14' => __( 'Ayutthaya (&#3614;&#3619;&#3632;&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3629;&#3618;&#3640;&#3608;&#3618;&#3634;)', 'rtPanel' ),
'TH-10' => __( 'Bangkok (&#3585;&#3619;&#3640;&#3591;&#3648;&#3607;&#3614;&#3617;&#3627;&#3634;&#3609;&#3588;&#3619;)', 'rtPanel' ),
'TH-38' => __( 'Bueng Kan (&#3610;&#3638;&#3591;&#3585;&#3634;&#3628;)', 'rtPanel' ),
'TH-31' => __( 'Buri Ram (&#3610;&#3640;&#3619;&#3637;&#3619;&#3633;&#3617;&#3618;&#3660;)', 'rtPanel' ),
'TH-24' => __( 'Chachoengsao (&#3593;&#3632;&#3648;&#3594;&#3636;&#3591;&#3648;&#3607;&#3619;&#3634;)', 'rtPanel' ),
'TH-18' => __( 'Chai Nat (&#3594;&#3633;&#3618;&#3609;&#3634;&#3607;)', 'rtPanel' ),
'TH-36' => __( 'Chaiyaphum (&#3594;&#3633;&#3618;&#3616;&#3641;&#3617;&#3636;)', 'rtPanel' ),
'TH-22' => __( 'Chanthaburi (&#3592;&#3633;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-50' => __( 'Chiang Mai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3651;&#3627;&#3617;&#3656;)', 'rtPanel' ),
'TH-57' => __( 'Chiang Rai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3619;&#3634;&#3618;)', 'rtPanel' ),
'TH-20' => __( 'Chonburi (&#3594;&#3621;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-86' => __( 'Chumphon (&#3594;&#3640;&#3617;&#3614;&#3619;)', 'rtPanel' ),
'TH-46' => __( 'Kalasin (&#3585;&#3634;&#3628;&#3626;&#3636;&#3609;&#3608;&#3640;&#3660;)', 'rtPanel' ),
'TH-62' => __( 'Kamphaeng Phet (&#3585;&#3635;&#3649;&#3614;&#3591;&#3648;&#3614;&#3594;&#3619;)', 'rtPanel' ),
'TH-71' => __( 'Kanchanaburi (&#3585;&#3634;&#3597;&#3592;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-40' => __( 'Khon Kaen (&#3586;&#3629;&#3609;&#3649;&#3585;&#3656;&#3609;)', 'rtPanel' ),
'TH-81' => __( 'Krabi (&#3585;&#3619;&#3632;&#3610;&#3637;&#3656;)', 'rtPanel' ),
'TH-52' => __( 'Lampang (&#3621;&#3635;&#3611;&#3634;&#3591;)', 'rtPanel' ),
'TH-51' => __( 'Lamphun (&#3621;&#3635;&#3614;&#3641;&#3609;)', 'rtPanel' ),
'TH-42' => __( 'Loei (&#3648;&#3621;&#3618;)', 'rtPanel' ),
'TH-16' => __( 'Lopburi (&#3621;&#3614;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-58' => __( 'Mae Hong Son (&#3649;&#3617;&#3656;&#3630;&#3656;&#3629;&#3591;&#3626;&#3629;&#3609;)', 'rtPanel' ),
'TH-44' => __( 'Maha Sarakham (&#3617;&#3627;&#3634;&#3626;&#3634;&#3619;&#3588;&#3634;&#3617;)', 'rtPanel' ),
'TH-49' => __( 'Mukdahan (&#3617;&#3640;&#3585;&#3604;&#3634;&#3627;&#3634;&#3619;)', 'rtPanel' ),
'TH-26' => __( 'Nakhon Nayok (&#3609;&#3588;&#3619;&#3609;&#3634;&#3618;&#3585;)', 'rtPanel' ),
'TH-73' => __( 'Nakhon Pathom (&#3609;&#3588;&#3619;&#3611;&#3600;&#3617;)', 'rtPanel' ),
'TH-48' => __( 'Nakhon Phanom (&#3609;&#3588;&#3619;&#3614;&#3609;&#3617;)', 'rtPanel' ),
'TH-30' => __( 'Nakhon Ratchasima (&#3609;&#3588;&#3619;&#3619;&#3634;&#3594;&#3626;&#3637;&#3617;&#3634;)', 'rtPanel' ),
'TH-60' => __( 'Nakhon Sawan (&#3609;&#3588;&#3619;&#3626;&#3623;&#3619;&#3619;&#3588;&#3660;)', 'rtPanel' ),
'TH-80' => __( 'Nakhon Si Thammarat (&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3608;&#3619;&#3619;&#3617;&#3619;&#3634;&#3594;)', 'rtPanel' ),
'TH-55' => __( 'Nan (&#3609;&#3656;&#3634;&#3609;)', 'rtPanel' ),
'TH-96' => __( 'Narathiwat (&#3609;&#3619;&#3634;&#3608;&#3636;&#3623;&#3634;&#3626;)', 'rtPanel' ),
'TH-39' => __( 'Nong Bua Lam Phu (&#3627;&#3609;&#3629;&#3591;&#3610;&#3633;&#3623;&#3621;&#3635;&#3616;&#3641;)', 'rtPanel' ),
'TH-43' => __( 'Nong Khai (&#3627;&#3609;&#3629;&#3591;&#3588;&#3634;&#3618;)', 'rtPanel' ),
'TH-12' => __( 'Nonthaburi (&#3609;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-13' => __( 'Pathum Thani (&#3611;&#3607;&#3640;&#3617;&#3608;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-94' => __( 'Pattani (&#3611;&#3633;&#3605;&#3605;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-82' => __( 'Phang Nga (&#3614;&#3633;&#3591;&#3591;&#3634;)', 'rtPanel' ),
'TH-93' => __( 'Phatthalung (&#3614;&#3633;&#3607;&#3621;&#3640;&#3591;)', 'rtPanel' ),
'TH-56' => __( 'Phayao (&#3614;&#3632;&#3648;&#3618;&#3634;)', 'rtPanel' ),
'TH-67' => __( 'Phetchabun (&#3648;&#3614;&#3594;&#3619;&#3610;&#3641;&#3619;&#3603;&#3660;)', 'rtPanel' ),
'TH-76' => __( 'Phetchaburi (&#3648;&#3614;&#3594;&#3619;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-66' => __( 'Phichit (&#3614;&#3636;&#3592;&#3636;&#3605;&#3619;)', 'rtPanel' ),
'TH-65' => __( 'Phitsanulok (&#3614;&#3636;&#3625;&#3603;&#3640;&#3650;&#3621;&#3585;)', 'rtPanel' ),
'TH-54' => __( 'Phrae (&#3649;&#3614;&#3619;&#3656;)', 'rtPanel' ),
'TH-83' => __( 'Phuket (&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;)', 'rtPanel' ),
'TH-25' => __( 'Prachin Buri (&#3611;&#3619;&#3634;&#3592;&#3637;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-77' => __( 'Prachuap Khiri Khan (&#3611;&#3619;&#3632;&#3592;&#3623;&#3610;&#3588;&#3637;&#3619;&#3637;&#3586;&#3633;&#3609;&#3608;&#3660;)', 'rtPanel' ),
'TH-85' => __( 'Ranong (&#3619;&#3632;&#3609;&#3629;&#3591;)', 'rtPanel' ),
'TH-70' => __( 'Ratchaburi (&#3619;&#3634;&#3594;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-21' => __( 'Rayong (&#3619;&#3632;&#3618;&#3629;&#3591;)', 'rtPanel' ),
'TH-45' => __( 'Roi Et (&#3619;&#3657;&#3629;&#3618;&#3648;&#3629;&#3655;&#3604;)', 'rtPanel' ),
'TH-27' => __( 'Sa Kaeo (&#3626;&#3619;&#3632;&#3649;&#3585;&#3657;&#3623;)', 'rtPanel' ),
'TH-47' => __( 'Sakon Nakhon (&#3626;&#3585;&#3621;&#3609;&#3588;&#3619;)', 'rtPanel' ),
'TH-11' => __( 'Samut Prakan (&#3626;&#3617;&#3640;&#3607;&#3619;&#3611;&#3619;&#3634;&#3585;&#3634;&#3619;)', 'rtPanel' ),
'TH-74' => __( 'Samut Sakhon (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3634;&#3588;&#3619;)', 'rtPanel' ),
'TH-75' => __( 'Samut Songkhram (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;)', 'rtPanel' ),
'TH-19' => __( 'Saraburi (&#3626;&#3619;&#3632;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-91' => __( 'Satun (&#3626;&#3605;&#3641;&#3621;)', 'rtPanel' ),
'TH-17' => __( 'Sing Buri (&#3626;&#3636;&#3591;&#3627;&#3660;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-33' => __( 'Sisaket (&#3624;&#3619;&#3637;&#3626;&#3632;&#3648;&#3585;&#3625;)', 'rtPanel' ),
'TH-90' => __( 'Songkhla (&#3626;&#3591;&#3586;&#3621;&#3634;)', 'rtPanel' ),
'TH-64' => __( 'Sukhothai (&#3626;&#3640;&#3650;&#3586;&#3607;&#3633;&#3618;)', 'rtPanel' ),
'TH-72' => __( 'Suphan Buri (&#3626;&#3640;&#3614;&#3619;&#3619;&#3603;&#3610;&#3640;&#3619;&#3637;)', 'rtPanel' ),
'TH-84' => __( 'Surat Thani (&#3626;&#3640;&#3619;&#3634;&#3625;&#3598;&#3619;&#3660;&#3608;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-32' => __( 'Surin (&#3626;&#3640;&#3619;&#3636;&#3609;&#3607;&#3619;&#3660;)', 'rtPanel' ),
'TH-63' => __( 'Tak (&#3605;&#3634;&#3585;)', 'rtPanel' ),
'TH-92' => __( 'Trang (&#3605;&#3619;&#3633;&#3591;)', 'rtPanel' ),
'TH-23' => __( 'Trat (&#3605;&#3619;&#3634;&#3604;)', 'rtPanel' ),
'TH-34' => __( 'Ubon Ratchathani (&#3629;&#3640;&#3610;&#3621;&#3619;&#3634;&#3594;&#3608;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-41' => __( 'Udon Thani (&#3629;&#3640;&#3604;&#3619;&#3608;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-61' => __( 'Uthai Thani (&#3629;&#3640;&#3607;&#3633;&#3618;&#3608;&#3634;&#3609;&#3637;)', 'rtPanel' ),
'TH-53' => __( 'Uttaradit (&#3629;&#3640;&#3605;&#3619;&#3604;&#3636;&#3605;&#3606;&#3660;)', 'rtPanel' ),
'TH-95' => __( 'Yala (&#3618;&#3632;&#3621;&#3634;)', 'rtPanel' ),
'TH-35' => __( 'Yasothon (&#3618;&#3650;&#3626;&#3608;&#3619;)', 'rtPanel' )
);
$states['US'] = array(
'AL' => __( 'Alabama', 'rtPanel' ),
'AK' => __( 'Alaska', 'rtPanel' ),
'AZ' => __( 'Arizona', 'rtPanel' ),
'AR' => __( 'Arkansas', 'rtPanel' ),
'CA' => __( 'California', 'rtPanel' ),
'CO' => __( 'Colorado', 'rtPanel' ),
'CT' => __( 'Connecticut', 'rtPanel' ),
'DE' => __( 'Delaware', 'rtPanel' ),
'DC' => __( 'District Of Columbia', 'rtPanel' ),
'FL' => __( 'Florida', 'rtPanel' ),
'GA' => __( 'Georgia', 'rtPanel' ),
'HI' => __( 'Hawaii', 'rtPanel' ),
'ID' => __( 'Idaho', 'rtPanel' ),
'IL' => __( 'Illinois', 'rtPanel' ),
'IN' => __( 'Indiana', 'rtPanel' ),
'IA' => __( 'Iowa', 'rtPanel' ),
'KS' => __( 'Kansas', 'rtPanel' ),
'KY' => __( 'Kentucky', 'rtPanel' ),
'LA' => __( 'Louisiana', 'rtPanel' ),
'ME' => __( 'Maine', 'rtPanel' ),
'MD' => __( 'Maryland', 'rtPanel' ),
'MA' => __( 'Massachusetts', 'rtPanel' ),
'MI' => __( 'Michigan', 'rtPanel' ),
'MN' => __( 'Minnesota', 'rtPanel' ),
'MS' => __( 'Mississippi', 'rtPanel' ),
'MO' => __( 'Missouri', 'rtPanel' ),
'MT' => __( 'Montana', 'rtPanel' ),
'NE' => __( 'Nebraska', 'rtPanel' ),
'NV' => __( 'Nevada', 'rtPanel' ),
'NH' => __( 'New Hampshire', 'rtPanel' ),
'NJ' => __( 'New Jersey', 'rtPanel' ),
'NM' => __( 'New Mexico', 'rtPanel' ),
'NY' => __( 'New York', 'rtPanel' ),
'NC' => __( 'North Carolina', 'rtPanel' ),
'ND' => __( 'North Dakota', 'rtPanel' ),
'OH' => __( 'Ohio', 'rtPanel' ),
'OK' => __( 'Oklahoma', 'rtPanel' ),
'OR' => __( 'Oregon', 'rtPanel' ),
'PA' => __( 'Pennsylvania', 'rtPanel' ),
'RI' => __( 'Rhode Island', 'rtPanel' ),
'SC' => __( 'South Carolina', 'rtPanel' ),
'SD' => __( 'South Dakota', 'rtPanel' ),
'TN' => __( 'Tennessee', 'rtPanel' ),
'TX' => __( 'Texas', 'rtPanel' ),
'UT' => __( 'Utah', 'rtPanel' ),
'VT' => __( 'Vermont', 'rtPanel' ),
'VA' => __( 'Virginia', 'rtPanel' ),
'WA' => __( 'Washington', 'rtPanel' ),
'WV' => __( 'West Virginia', 'rtPanel' ),
'WI' => __( 'Wisconsin', 'rtPanel' ),
'WY' => __( 'Wyoming', 'rtPanel' ),
'AA' => __( 'Armed Forces (AA)', 'rtPanel' ),
'AE' => __( 'Armed Forces (AE)', 'rtPanel' ),
'AP' => __( 'Armed Forces (AP)', 'rtPanel' ),
'AS' => __( 'American Samoa', 'rtPanel' ),
'GU' => __( 'Guam', 'rtPanel' ),
'MP' => __( 'Northern Mariana Islands', 'rtPanel' ),
'PR' => __( 'Puerto Rico', 'rtPanel' ),
'UM' => __( 'US Minor Outlying Islands', 'rtPanel' ),
'VI' => __( 'US Virgin Islands', 'rtPanel' ),
);
$states['ZA'] = array(
'EC' => __( 'Eastern Cape', 'rtPanel' ) ,
'FS' => __( 'Free State', 'rtPanel' ) ,
'GP' => __( 'Gauteng', 'rtPanel' ) ,
'KZN' => __( 'KwaZulu-Natal', 'rtPanel' ) ,
'LP' => __( 'Limpopo', 'rtPanel' ) ,
'MP' => __( 'Mpumalanga', 'rtPanel' ) ,
'NC' => __( 'Northern Cape', 'rtPanel' ) ,
'NW' => __( 'North West', 'rtPanel' ) ,
'WC' => __( 'Western Cape', 'rtPanel' )
);
if ($c == '') {
return $countries;
} elseif ($c != '') {
if(!$only_country){
$selected_country = '';
if (strlen($c) > 2) {
foreach ($countries as $cc => $country) {
if ($country == $c) {
$selected_country = $cc;
}
}
}
else
$selected_country = $c; /* Assuming that none of the countries name is 2 character long, it must be the country key */
if ($selected_country != '' && in_array($selected_country, $states)) {
global $states;
return $states[$selected_country];
} elseif (!in_array($selected_country, $states))
return NULL;
}
/* If $only_country is set to true, it will return only country name */
if($only_country){
return $countries[$c];
}
}
} // End of Function
// Timezone
function formatOffset($offset) {
$hours = $offset / 3600;
$remainder = $offset % 3600;
$sign = $hours > 0 ? '+' : '-';
$hour = (int) abs($hours);
$minutes = (int) abs($remainder / 60);
if ($hour == 0 AND $minutes == 0) {
$sign = ' ';
}
return $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) .':'. str_pad($minutes,2, '0');
}
/* Get Timezone List */
function get_timzone_list(){
$utc = new DateTimeZone('UTC');
$dt = new DateTime('now', $utc);
$options = '';
foreach(DateTimeZone::listIdentifiers() as $tz) {
$current_tz = new DateTimeZone($tz);
$offset = $current_tz->getOffset($dt);
$transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
$abbr = $transition[0]['abbr'];
$options .= '<option value="' .$tz. '">' .$tz. ' [' .$abbr. ' '. formatOffset($offset). ']</option>';
}
return $options;
}
/* Filter Timezone List */
function rtp_filter_timzone_callback($country_code){
if(!empty($country_code)){
$utc = new DateTimeZone('UTC');
$dt = new DateTime('now', $utc);
if($country_code !='' && $country_code != '#'){
$timezone_list = '';
$filtered_timezone = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $country_code);
foreach($filtered_timezone as $timezone){
$current_tz = new DateTimeZone($timezone);
$offset = $current_tz->getOffset($dt);
$transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
$abbr = $transition[0]['abbr'];
$timezone_list .='<option value="' .$timezone. '">' .$timezone. ' [' .$abbr. ' '. formatOffset($offset). ']</option>';
}
return $timezone_list;
}else
return get_timzone_list();
}
die(1);
}
//Examples for the function
$countries = get_country_state_list(); /* Returns an Array of all countries */
$country_code = "IN";
$country_name = get_country_state_list($country_code, TRUE); //Return Country Name for the Country Code
$states = get_country_state_list($country_code); //Where IN is country code for India, You can pass any thing if there is a state list it returns a array, otherwise "No States"
$timezone_list = rtp_filter_timzone_callback(); // returns a list of all timezones if null is given as an argument/ otherwise list of timezone for the specific country as an option value which can be directly echoed in a select dropdown
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment