Reputation: 421
I am using Google Time Zone API to retrieve time zone, my code is
$lat = round($location['lat'], 2);
$lng = round($location['lng'], 2);
$url = "https://maps.googleapis.com/maps/api/timezone/jsonlocation=".$lat.",".$lng."&timestamp=1419283200&sensor=false";
$url = str_replace(' ','',$url);
$json_timezone = file_get_contents($url);
echo $url;
echo '<pre>';print_r($json_timezone);
And the output is
https://maps.googleapis.com/maps/api/timezone/json?location=39.29,-76.64×tamp=1419283200&sensor=false
{
"status" : "INVALID_REQUEST"
}
When I run the above url, I get the correct output
{
"dstOffset" : 0,
"rawOffset" : -18000,
"status" : "OK",
"timeZoneId" : "America/New_York",
"timeZoneName" : "Eastern Standard Time"
}
Any Idea how to solve this
Upvotes: 0
Views: 1351
Reputation: 43552
Your $url
is invalid. Try this:
$url = "https://maps.googleapis.com/maps/api/timezone/json?location=".$lat.",".$lng."×tamp=1419283200&sensor=false";
Upvotes: 2