Free Rest API to retrieve current datetime as string (timezone irrelevant)

chadoh picture chadoh · Nov 5, 2012 · Viewed 116k times · Source

I am seeking a reliable REST API that can provide world time and time zone information across platforms.

I need the current time as a string. I'd like it to return the result in under a second, regardless of the user's location worldwide.

Among other implementations I want to use this for a consistent countdown timer, to be more accurate than a user's [possibly-inaccurate] computer time. It can be GMT or another time zone, as long as the time zone and offset is specified, like 2012-11-05 16:16:50 EST.

I would build this API myself, but have concerns of potential latency issues (as well as inelegance) when filtering someone through a whole big software stack like Rails just to return a simple String.

Excessive latency for users far away from the US east coast would offset the benefit of accuracy that the task requires.

Any suggestions and/or examples are appreciated.

Answer

Aamir picture Aamir · Nov 5, 2012

TimezoneDb provides a free API: http://timezonedb.com/api

GenoNames also has a RESTful API available to get the current time for a given location: http://www.geonames.org/export/ws-overview.html.

You can use Greenwich, UK if you'd like GMT.