免费的Rest API,以字符串形式检索当前日期时间(与时区无关) [英] Free Rest API to retrieve current datetime as string (timezone irrelevant)

查看:115
本文介绍了免费的Rest API,以字符串形式检索当前日期时间(与时区无关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种可靠的 REST API ,该API可以提供跨平台的世界时间和时区信息.

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.

在其他实现中,我想将其用于一致的倒数计时器,以比用户的[可能不准确]的计算机时间更准确.只要指定了时区和偏移量,它就可以是格林尼治标准时间或其他时区,例如2012-11-05 16:16:50 EST.

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.

我会自己构建此API,但是在通过诸如Rails之类的整个大型软件堆栈过滤某人以返回简单的String时,我会担心潜在的延迟问题(以及优雅).

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.

推荐答案

如果您使用的是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天全站免登陆