如何存储不同时区的日期时间 [英] how to store date time for different time zones

查看:64
本文介绍了如何存储不同时区的日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端浏览器中存储应转换为不同时区的服务器时间。



存储将被转换的日期时间的最佳方法是什么到本地日期时间..

I want to store the server time which should be Converted to different time zones at client browser.

What is the best way to store datetime that will be converted to local datetime..

推荐答案

您应始终将服务器时间存储为UTC DateTime 对象。这是服务器时间减去服务器的时区偏移量。所有系统都提供了一种从操作系统获取此时间值的方法。然后,客户端系统可以在需要显示时将其本地时区偏移量添加到此值。
You should always store the server time as a UTC DateTime object. That is the server time less the server's timezone offset. All systems provide a method to get this time value from the operating system. The client systems can then add their local timezone offset to this value when they need to display it.


这篇关于如何存储不同时区的日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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