Jump to content

Get timezone for a city?


Robin S
 Share

Recommended Posts

Does anyone know of a website/tool that will let me type in the name of a city, or maybe click on a map, and get the PHP-compatible timezone name for that location?

So for example if I typed or clicked on the location Christchurch, New Zealand I would get "Pacific/Auckland".

It doesn't need to be an API or anything - I just need some way to manually look up timezones for different locations.

Link to comment
Share on other sites

I'm yet to find the perfect solution but so far I have found...

Search by location name (somewhat clunky and slow): https://www.geonames.org/

Click on map (can't search by name): https://askgeo.com/

Enter latitude and longitude (can't search by name): https://timezonedb.com/

For my needs I prefer a web interface but if I wanted or could be bothered with an API I found several listed in this StackOverflow answer

Link to comment
Share on other sites

There's a really useful page https://stackoverflow.com/tags/timezone/info - though it'll make you realise you're opening something of a can of worms! 

I think, but I'm definitely not sure, that PHP uses the IANA/Olson Time Zone Database (linked on the above page). However, even if it does, I don't know how up to date PHPs list of time zones is.

The Geolite2 database from MaxMind, at https://dev.maxmind.com/geoip/geoip2/geolite2/, is free and gives IANA time zone codes. This is another option: https://www.ip2location.com/free/olson-timezone. And there may well be quite a few other such sources out there.

I don't know of any ready-made tool, but that doesn't mean there isn't one!

  • Like 1
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...