Robin S Posted February 24, 2021 Share Posted February 24, 2021 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 More sharing options...
Robin S Posted February 24, 2021 Author Share Posted February 24, 2021 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 More sharing options...
3fingers Posted February 24, 2021 Share Posted February 24, 2021 To me it looks like https://www.timeanddate.com/time/map/ is doing what you're after. You can search by name and then you have the timezone of the city you've entered inside the "Timezone" tab. 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 24, 2021 Author Share Posted February 24, 2021 9 minutes ago, 3fingers said: To me it looks like https://www.timeanddate.com/time/map/ is doing what you're after. Thanks, but I already looked at this one and it doesn't give the timezone in the PHP name format I linked to in my post. It gives a timezone like "PST" when I need "America/Los_Angeles". 1 Link to comment Share on other sites More sharing options...
ottogal Posted February 24, 2021 Share Posted February 24, 2021 Maybe this would do it: https://www.zeitverschiebung.net/en/city/2192362 1 Link to comment Share on other sites More sharing options...
BillH Posted February 24, 2021 Share Posted February 24, 2021 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! 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 24, 2021 Author Share Posted February 24, 2021 10 hours ago, ottogal said: Maybe this would do it: https://www.zeitverschiebung.net/en/city/2192362 Nice, that's the quickest and easiest I've seen so far. Thanks! Link to comment Share on other sites More sharing options...
Robin S Posted February 24, 2021 Author Share Posted February 24, 2021 2 hours ago, BillH said: I don't know how up to date PHPs list of time zones is. The PHP timezones are stored in timezonedb, which is updated regularly: https://pecl.php.net/package/timezonedb You can check which version is used in your environment via timezone_version_get(). 1 Link to comment Share on other sites More sharing options...
BillH Posted February 25, 2021 Share Posted February 25, 2021 Thanks @Robin S, useful to know. Link to comment Share on other sites More sharing options...
Recommended Posts