在 JavaScript 时钟上使用时区
我想使用这样的时钟:
它只输出当前时间并继续向上计数。是否可以使用这个时钟,但也可以使用时区?
我目前正在使用此代码输出页面在不同时区加载的时间:
$myDateTime->setTimezone(new DateTimeZone($timezone));
$myDateTime->format('H:i:s');
变量 $timezone 是从数据库设置的,例如包含“欧洲/伦敦”或“亚洲/Ho_Chi_Minh”。
如果有人可以帮助我让时钟在 $timezone 设置的时区工作,我将非常感激。
感谢您的帮助
编辑:我找到了本教程 http://networking。 mydesigntool.com/viewtopic.php?tid=373&id=31 展示了如何在欧洲/伦敦时区等运行简单的 javascript 时钟和过滤器。希望这对将来的人们有一些用处
I would like to use a clock like this one:
which just outputs the current time and continues counting upwards. Is it possible to use this clock but to use timezones with it too?
I am currently using this code to output the time the page was loaded in different timezones:
$myDateTime->setTimezone(new DateTimeZone($timezone));
$myDateTime->format('H:i:s');
The variable $timezone is set from the database and contains 'Europe/London' or 'Asia/Ho_Chi_Minh' for example.
If someone could help me to get that clock working in the timezone set by $timezone I would really appreciate it.
Thanks for any help
edit: I have found this tutorial http://networking.mydesigntool.com/viewtopic.php?tid=373&id=31 which shows how to run a simple javascript clock and filter in the Europe/London timezones etc. Hopefully this is of some use to people in the future
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用类似的东西。
预览
这是我基于 PHP 和 JavaScript 中的时区的旧 PHP 代码向上计数。
下载代码并尝试对其进行调整以满足您的需求。
我想你需要类似的东西。
You can use something like this.
Preview:
That's my old PHP code based on timezones in PHP and JavaScript to count upwards.
Download code and try to adapt it to suit your needs.
I guess you need something like that.