开发者

Is there any json rest service out there that allows a javascript webapp to get the current UTC time?

开发者 https://www.devze.com 2023-02-20 08:52 出处:网络
I\'m looking for something 开发者_如何学Pythonlike http://time.is/UTC but with an interface for web applications.If you don\'t need an SLA-level service, there\'s a service here on Google App engine t

I'm looking for something 开发者_如何学Pythonlike http://time.is/UTC but with an interface for web applications.


If you don't need an SLA-level service, there's a service here on Google App engine that speaks JSONP: http://json-time.appspot.com/

Requesting http://json-time.appspot.com/time.json will return an object like this:

{
  "tz": "UTC", 
  "hour": 23, 
  "datetime": "Wed, 30 Mar 2011 23:03:55 +0000", 
  "second": 55, 
  "error": false, 
  "minute": 3
}

If you append ?callback=yourJsonCallback, it will respond like:

yourJsonCallback({
  "tz": "UTC", 
  "hour": 23, 
  "datetime": "Wed, 30 Mar 2011 23:05:36 +0000", 
  "second": 36, 
  "error": false, 
  "minute": 5
})

James Padolsey has a nice blog post demonstrating how to consume the service with plain JavaScript and a variety of libraries like jQuery: http://james.padolsey.com/uncategorized/getting-the-real-time-in-javascript/


Does this fulfill your needs: http://developer.yahoo.com/util/timeservice/V1/getTime.html


Then there is this one : http://www.nanonull.com/TimeService/TimeService.asmx/getUTCTime It returns UTC in the following format :

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.Nanonull.com/TimeService/">10:43 PM</string>

Which actually seems less helpful.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号