如何使用javascript获取特定时区的时间,但与当前系统时间无关? [英] How to get the time of specific timezone using javascript, but without being relevant to the current system time?

查看:142
本文介绍了如何使用javascript获取特定时区的时间,但与当前系统时间无关?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,在将此标记为重复之前,请注意,可能的重复中的所有有用答案都提供与当前系统时间相关的功能,这是我不能接受的。



我想要的是,目前的时间,例如纽约,与所有用户一致,无论他们的时间设置如何。


$ b $例如,我在这里有两台电脑,其中一台电脑相对于另外两台电脑,这样会留下一个不可接受的差距,因为我的任务涉及精确的精度(稍微夸张,但是你知道我的意思)。



我如何克服这个?我必须得到服务器的时间,并以某种方式转换它?如果是这样,我正在使用PHP。

解决方案

希望不要错误,但javascript加载在用户机器上,而不是在服务器,所以你会一直使用javascript获取访问者的日期/时间。您可以使用php获取日期/时间,因为在服务器上加载并将日期传递给javascript。



希望这个帮助


Now, before you mark this as a duplicate, please note that all the useful answers in the possible duplicate provide functions which work in relation to the current system time, which I cannot accept.

What I want, is that the current time in, say, for example, New York, be consistent to all users, no matter what their time settings are.

For example, I have two computers here, and one is 3 seconds behind the other, and this leaves an unacceptable gap, as my task involve pinpoint precision (slightly exaggerated, but you know what I mean).

How can I overcome this? Must I get the server time and somehow convert it? If so, I'm using PHP.

解决方案

Hope to not be wrong but javascript is loaded on user machine, not on the server so you will allway get the visitor date/time using javascript. you can use php to get the date/time because is loaded on the server and pass the dates to javascript.

Hope this help

这篇关于如何使用javascript获取特定时区的时间,但与当前系统时间无关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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