There is a city in the Russian layout for example (Moscow), or rather there is a base from almost all cities of the world, how to determine the time zone in each of the cities? Is there an API that returns data around the city?

PS PHP

  • google.ru/… - Visman
  • do not learn manually !!! Did you read? - vupsen
  • I read that. Don't you know what parsing is? You take a suitable site and parse the data from it or contact the admins and if they are sane, you can easily share the base city-time zone. - Visman Sep.
  • parsing will not work here (I mean the pages) - vupsen
  • You probably did not understand me. You parse all the cities composing your correspondence table, then import it into your database on the site and use the data from your database. There is no need to parse in real time. - Visman Sep. 1:14 pm

1 answer 1

There is a GeoIP API in PHP: http://www.php.net/manual/ru/ref.geoip.php
You need the geoip_time_zone_by_country_and_region () function

  • I read about geo, but there you need to know the country codes and the region code, if the country code there you can still get what to do with the region code ( - vupsen
  • There is a function geoip_region_by_name, which returns the region code by its name. - Michael Vaysman
  • php.net/manual/ru/function.geoip-country-code-by-name.php I need to set the host address in the parameter, but I need to go around the city! - vupsen
  • Then there is the Google Time Zone API. There, of course, you first need to register, but it should not work badly. There are limitations of course ... 2500 requests per day and 5 requests per second. Here's the link: developers.google.com/maps/documentation/timezone/intro - Michael Vaysman Sept
  • I’m already smoking in his direction, although with crutches in terms of there, he will get the name for example Europe / Moscow, transferring coordinates from the map to him (having determined them), then we will specify the timezone in php and get time, but these are braces ... .. And it also fails to get the key, PS there is even a developer console - vupsen