Home > Blockchain >  PHP 8.1 - Laravel - Geoip find timezone by country and region
PHP 8.1 - Laravel - Geoip find timezone by country and region

Time:01-20

I want to find the timezone with the country and region using

geoip_time_zone_by_country_and_region()

but seems it needs geoip ext to be installed which is not supported anymore and seems geoip2 just works with IP but I want to get the timezone by country and region(state) name is there any solution? I'm using Laravel 9 and PHP 8.1

CodePudding user response:

2 choices

Get free versions of maxmind geoip (Geolite DB) and use them . Cumbersome for just the zone

Use javascript Time Zones in South Daktoa

geoip_time_zone_by_country_and_region("US", "SD") is hardcoded to return "America/Chicago" - which is the IANA time zone identifier for US Central Time - which applies in the eastern half of South Daktoa only. The western half should use "America/Denver" instead.

Any approach to resolving a time zone needs to take much more than just country and region into account. A more accurate approach would be to use latitude and longitude coordinates, which could be resolved from an address (or at least a country, region, and city) via a number of different techniques.

  • Related