Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Echo status message in php geonames timezone

Tags:

I'm using following code php to get timezone:

$url = 'http://api.geonames.org/timezone?lat=' . $latitude . '&lng=' . $longitude . '&username=demo';
        $xml = simplexml_load_file($url);

        foreach($xml->children() as $timezone)
        {


            echo "TimezoneId: ".$timezone->timezoneId." ";
            echo "DstOffset : ".$timezone->dstOffset." ";
            echo "GmtOffset : ".$timezone->gmtOffset." ";

}

it work but for latitude and longitude of Antartica for example it give error status message:

<status message="no timezone information found for lat/lng" value="15"/>

How to echo this message?

I'm tryng this:

if ($xml->status) {
    echo "error: ".$timezone->status['message']. "";


         }

but don't work