Can anyone please tell me if there is any way available in PHP to fetch timezone region like(\'Asia/Calcutta\') from IP Address or country name?
Description:
<
If you want to do it on the server side, you can do this with PHP:
$url = "https://ipsidekick.com/json";
$result = file_get_contents($url);
$json = json_decode($result, true);
print("It's " . $json["gmtOffset"] . " at " . $json["timeZoneName"]);
Note that this is synchronous.
Alternatively, if you can do it on the client side. You can use this with jQuery or equivalent:
$.get("https://ipsidekick.com/json", function(response) {
console.log(response.ip +
" It's " + response.gmtOffset +
" from " + response.timeZoneName);
});
Disclaimer: I run IP Sidekick.