Web service - current time zone for a city?

2019-01-01 08:44发布

Is there a web service of some sort (or any other way) to pull a current time zone settings for a (US) city. For the parts of the country that don't follow the Daylight Saving Time and basically jump timezones when everyone else is switching summer/winter time... I don't fancy creating own database of the places that don't follow DST. Is there a way to pull this data on demand?

I need this for the database server (not for client workstations) - there entities stored in the database that have City, State as properties. I need know current timezone for these entities at any moment of time.

10条回答
回忆,回不去的记忆
2楼-- · 2019-01-01 09:27

Earthtool's timezone info is not up to date ... for an instance, the Sri Lankan current offset is +5.5 from GMT but EarthTools shows as +6 which was the old offset before 2005.

I suggest GeoNames.org.

查看更多
只若初见
3楼-- · 2019-01-01 09:28

Simple Offline Library : APTimeZones

In order to find the time zone for a location you can use such as the Google Maps API’s time zone API. Unfortunately this requires you to query a remote service and you are subject to their limits.

Here’s a library rom Alterplay called APTimeZones(Git is attached) that allows you to extract an NSTimeZone from a given location without the need to connect to a remote service. APTimeZones works by querying a local listing of time zones (included with the library).

查看更多
宁负流年不负卿
4楼-- · 2019-01-01 09:29

I know this is answered, but I am posting this answer as people might still find it useful - The selected answer does not work successfuly right now.

Google have their own service, which is very reliable and easy to use, and outputs info in JSON format. It even allows for specifying a custom time, e.g get the timezone in 02/02/2013 in Malta.

https://developers.google.com/maps/documentation/timezone/

查看更多
呛了眼睛熬了心
5楼-- · 2019-01-01 09:31

WorldTimeServer.com has what appears to be a comprehensive time zone database, which you can purchase access to in a variety of formats, including a .NET component for Web use.

No connection, just had to research the same thing myself recently.

查看更多
登录 后发表回答