开发者

Timezone independent time at client side

I need to obtain the server time but I only have javascript to play with. I need the time from the NA and EU regions. Is there a way to obtain server time. OR is there a JS code snippet that can help me achieve the same?

Just to make things clear, I am not looking for UTC. I haev an application that will do something for the user at a certain time. The application will be u开发者_开发知识库sed in NA and EU regions where there is a time difference. I need the time from the server. Can it be done?


With jquery, i found this plugin.


You may want to consider using UTC, so your users see a unified time instead of trying to display the server time.

http://www.w3schools.com/jsref/jsref_getutcdate.asp


The most reliable way of determining the time from the server is to ask it !

Anything derived from the client's clock will be more prone to clock skew or other errors because client machines don't usually have decent synchronisation methods like NTPv3 that are typically deployed on servers.

A trivial CGI script (PHP, perl, whatever) on the server combined with an AJAX call to get the data would do the job nicely.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜