timezone_location_get


world apg

RETURNS the location information for a timezone.



<?php

/* - - - - - - - - - - - - - - - - -

    Object oriented style
   
   - - - - - - - - - - - - - - - - - */

arr|false public arr DateTimeZone::getLocation ( )


?>

<?php
 
   
/* - - - - - - - - - - - - - - - - -

      Procedural style
   
   - - - - - - - - - - - - - - - - - */

arr|false timezone_location_get DateTimeZone $object )

where

$object Object returned by timezone_open function


?>

 $object 


Object returned by the function timezone_open.





This function returns an ARRAY containing the location information about the Time Zone or FALSE on failure.



  1 EXERCISE   

<?php

setlocale
(LC_ALL"pt_BR.utf-8""portuguese-brazil""ptb"); 

$obj_tz01 = new DateTimeZone("America/Sao_Paulo");

$arr_loc01 timezone_location_get($obj_tz01);

foreach(
$arr_loc01 as $arrl01 => $al01)
{
    echo 
$arrl01 '&nbsp;=>&nbsp;' $al01 '<br><br>';
}

?>

 RESULT   

country_code => BR

latitude => -23,53334

longitude => -46,61667

comments => Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS)

LIST OF TIME ZONES


The specified object must match the one specified names in the below table:

Timezone NAMETimezone NAME
Africa/AbidjanAfrica/Accra
Africa/AlgiersAfrica/Asmara
Africa/BanguiAfrica/Banjul
Africa/BlantyreAfrica/Brazzaville
Africa/CairoAfrica/Casablanca
Africa/ConakryAfrica/Dakar
Africa/DjiboutiAfrica/Douala
Africa/FreetownAfrica/Gaborone
Africa/JohannesburgAfrica/Juba
Africa/KhartoumAfrica/Kigali
Africa/LagosAfrica/Libreville
Africa/LuandaAfrica/Lubumbashi
Africa/MalaboAfrica/Maputo
Africa/MbabaneAfrica/Mogadishu
Africa/NairobiAfrica/Ndjamena
Africa/NouakchottAfrica/Ouagadougou
Africa/Sao_TomeAfrica/Tripoli
Africa/WindhoekAmerica/Adak
America/AnguillaAmerica/Antigua
America/Argentina/Buenos_AiresAmerica/Argentina/Catamarca
America/Argentina/JujuyAmerica/Argentina/La_Rioja
America/Argentina/Rio_GallegosAmerica/Argentina/Salta
America/Argentina/San_LuisAmerica/Argentina/Tucuman
America/ArubaAmerica/Asuncion
America/BahiaAmerica/Bahia_Banderas
America/BelemAmerica/Belize
America/Boa_VistaAmerica/Bogota
America/Cambridge_BayAmerica/Campo_Grande
America/CaracasAmerica/Cayenne
America/ChicagoAmerica/Chihuahua
America/CrestonAmerica/Cuiaba
America/DanmarkshavnAmerica/Dawson
America/DenverAmerica/Detroit
America/EdmontonAmerica/Eirunepe
America/Fort_NelsonAmerica/Fortaleza
America/GodthabAmerica/Goose_Bay
America/GrenadaAmerica/Guadeloupe
America/GuayaquilAmerica/Guyana
America/HavanaAmerica/Hermosillo
America/Indiana/KnoxAmerica/Indiana/Marengo
America/Indiana/Tell_CityAmerica/Indiana/Vevay
America/Indiana/WinamacAmerica/Inuvik
America/JamaicaAmerica/Juneau
America/Kentucky/MonticelloAmerica/Kralendijk
America/LimaAmerica/Los_Angeles
America/MaceioAmerica/Managua
America/MarigotAmerica/Martinique
America/MazatlanAmerica/Menominee
America/MetlakatlaAmerica/Mexico_City
America/MonctonAmerica/Monterrey
America/MontserratAmerica/Nassau
America/NipigonAmerica/Nome
America/North_Dakota/BeulahAmerica/North_Dakota/Center
America/OjinagaAmerica/Panama
America/ParamariboAmerica/Phoenix
America/Port_of_SpainAmerica/Porto_Velho
America/Punta_ArenasAmerica/Rainy_River
America/RecifeAmerica/Regina
America/Rio_BrancoAmerica/Santarem
America/Santo_DomingoAmerica/Sao_Paulo
America/SitkaAmerica/St_Barthelemy
America/St_KittsAmerica/St_Lucia
America/St_VincentAmerica/Swift_Current
America/ThuleAmerica/Thunder_Bay
America/TorontoAmerica/Tortola
America/WhitehorseAmerica/Winnipeg
America/YellowknifeAntarctica/Casey
Antarctica/DumontDUrvilleAntarctica/Macquarie
Antarctica/McMurdoAntarctica/Palmer
Antarctica/SyowaAntarctica/Troll
Arctic/LongyearbyenAsia/Aden
Asia/AmmanAsia/Anadyr
Asia/AqtobeAsia/Ashgabat
Asia/BaghdadAsia/Bahrain
Asia/BangkokAsia/Barnaul
Asia/BishkekAsia/Brunei
Asia/ChoibalsanAsia/Colombo
Asia/DhakaAsia/Dili
Asia/DushanbeAsia/Famagusta
Asia/HebronAsia/Ho_Chi_Minh
Asia/HovdAsia/Irkutsk
Asia/JayapuraAsia/Jerusalem
Asia/KamchatkaAsia/Karachi
Asia/KhandygaAsia/Kolkata
Asia/Kuala_LumpurAsia/Kuching
Asia/MacauAsia/Magadan
Asia/ManilaAsia/Muscat
Asia/NovokuznetskAsia/Novosibirsk
Asia/OralAsia/Phnom_Penh
Asia/PyongyangAsia/Qatar
Asia/RiyadhAsia/Sakhalin
Asia/SeoulAsia/Shanghai
Asia/SrednekolymskAsia/Taipei
Asia/TbilisiAsia/Tehran
Asia/TokyoAsia/Tomsk
Asia/UrumqiAsia/Ust-Nera
Asia/VladivostokAsia/Yakutsk
Asia/YekaterinburgAsia/Yerevan
Atlantic/BermudaAtlantic/Canary
Atlantic/FaroeAtlantic/Madeira
Atlantic/South_GeorgiaAtlantic/St_Helena
Australia/AdelaideAustralia/Brisbane
Australia/CurrieAustralia/Darwin
Australia/HobartAustralia/Lindeman
Australia/MelbourneAustralia/Perth
Europe/AmsterdamEurope/Andorra
Europe/AthensEurope/Belgrade
Europe/BratislavaEurope/Brussels
Europe/BudapestEurope/Busingen
Europe/CopenhagenEurope/Dublin
Europe/GuernseyEurope/Helsinki
Europe/IstanbulEurope/Jersey
Europe/KievEurope/Kirov
Europe/LjubljanaEurope/London
Europe/MadridEurope/Malta
Europe/MinskEurope/Monaco
Europe/OsloEurope/Paris
Europe/PragueEurope/Riga
Europe/SamaraEurope/San_Marino
Europe/SaratovEurope/Simferopol
Europe/SofiaEurope/Stockholm
Europe/TiraneEurope/Ulyanovsk
Europe/VaduzEurope/Vatican
Europe/VilniusEurope/Volgograd
Europe/ZagrebEurope/Zaporozhye
Indian/AntananarivoIndian/Chagos
Indian/CocosIndian/Comoro
Indian/MaheIndian/Maldives
Indian/MayotteIndian/Reunion
Pacific/AucklandPacific/Bougainville
Pacific/ChuukPacific/Easter
Pacific/EnderburyPacific/Fakaofo
Pacific/FunafutiPacific/Galapagos
Pacific/GuadalcanalPacific/Guam
Pacific/KiritimatiPacific/Kosrae
Pacific/MajuroPacific/Marquesas
Pacific/NauruPacific/Niue
Pacific/NoumeaPacific/Pago_Pago
Pacific/PitcairnPacific/Pohnpei
Pacific/RarotongaPacific/Saipan
Pacific/TarawaPacific/Tongatapu
Pacific/WallisUTC
ed48


  2 EXERCISE   

<?php

setlocale
(LC_ALL"en_GB""eng""english-uk""uk"); 

$obj_tz02 = new DateTimeZone("Europe/London");

$arr_loc02 timezone_location_get($obj_tz02);

foreach(
$arr_loc02 as $k02 => $v02)
echo 
$k02 ' => ' $v02 '<br><br>';

?>

 RESULT   

country_code => GB

latitude => 51.50833

longitude => -0.12527

comments =>


  3 EXERCISE   

<?php

setlocale
(LC_ALL"en_GB""eng""english-uk""uk"); 

$obj_tz03 = new DateTimeZone("UTC");

$arr_loc03 timezone_location_get($obj_tz03);

foreach(
$arr_loc03 as $k03 => $v03)
echo 
$k03 ' => ' $v03 '<br><br>';

?>

  4 EXERCISE   

<?php

$loc04 
setlocale(LC_ALL"en_GB""eng""english-uk""uk"); 

$obj_tz04 = new DateTimeZone();

// Attention - beware of this line of code
// Fatal error is expected - 
// - regardless of the version of PHP used

// Remember that this type of error interrupts 
// the programming flow

$arr_loc04 timezone_location_get($obj_tz04);

print_r($arr_loc04);

?>

  5 EXERCISE   

<?php

$tz05 
DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY'US'); 

foreach(
$tz05 as $zn05)
{
    
    
$objtz05 = new DateTimeZone($zn05);
    
    
$loc05 $objtz05->getLocation();
    
    echo 
'[ ' $loc05['country_code'] . ']<br>' 
    
$zn05 '<br>' $loc05['comments'] . 
    
'<br>( ' $loc05['latitude'] . ', ' 
    
$loc05['longitude'] . ' )<br><br>';
    
}

?>