免费REST API来获取当前的时间串(时区无关) [英] Free Rest API to get current time as string (timezone irrelevant)

查看:206
本文介绍了免费REST API来获取当前的时间串(时区无关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以设置此我自己,但功能的 SOOO 的简单,它似乎像别人可能已经做到了更好,更快的比我可以用我的Rails应用程序。

I could set this up myself, but the functionality is sooo simple that it seems like someone else probably already did it better and faster than I could with my Rails app.

我需要当前时间为一个字符串。我想它比第二,无论我的客人恰好是在全球范围内少返回。 (我在做一个倒数计时器,它需要比用户可能关闭计算机时更准确)。它可以是GMT时间。不要紧,只要它说的时区(如2012年11月5日16时16分50秒EST)。

I need the current time as a string. I'd like it to return within less than a second, wherever my visitor happens to be in the world. (I'm making a countdown timer, and it needs to be more accurate than a user's possibly-off computer time.) It can be GMT time. Doesn't matter, as long as it says the time zone (like "2012-11-05 16:16:50 EST").

(我可以通过像一个整体的大的软件栈建立这个我自己,当然,这是一个简单的API,但我的服务器都位于美国东海岸,而我整个Rails的堆栈中的工作。滤波人导轨只是返回一个字符串似乎不雅,我很担心潜伏期为游客远离美国东海岸。)

(I could build this myself, of course. It's a simple API. But my servers are on the east coast of the US, and I'm working within a whole Rails stack. Filtering someone through a whole big software stack like Rails just to return a string seems inelegant, and I'm worried about the latency for visitors far away from the US east coast.)

推荐答案

如果你正在使用Rails,你可以只是使公共文件夹,并使用了Ajax一个空文件来获取。然后解析头,在日期的头。在公用文件夹忽略文件的Rails堆栈,因此拥有更低的延迟。

If you're using Rails, you can just make an empty file in the public folder and use ajax to get that. Then parse the headers for the Date header. Files in the Public folder bypass the Rails stack, and so have lower latency.

这篇关于免费REST API来获取当前的时间串(时区无关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆