简体   繁体   English

服务器和HTML客户端的时区问题

[英]Time Zone issue with server and html client

Basic requirement is Server has data with GMT +00.00 and Browser needs to request data from server between certain dates(not time). 基本要求是服务器具有GMT +00.00的数据,并且浏览器需要在特定日期(而非时间)之间向服务器请求数据。 Let's say, one record saved on server on 28th March,2015 Night from USA local time. 假设某条记录是从美国当地时间2015年3月28日晚上保存在服务器上的。 Server is following GMT +00.00 so record saved with 29th March, 2015 morning with GMT. 服务器正在遵循GMT +00.00,因此记录已于2015年3月29日上午GMT保存。

Now HTML is retrieving same record from the server. 现在,HTML正在从服务器检索相同的记录。 Server have GMT 29th March,2015. 服务器于2015年3月29日格林尼治标准时间。 But now I want to display local date as per time zone of any browser. 但是现在我想按任何浏览器的时区显示本地日期。 Client and server is communication with date only not time. 客户端和服务器仅使用日期而不是时间进行通信。

Right now server will give 29th March, 2015 to client. 现在,服务器会给2015年3月29日至客户端。 But It should display as a local date ie 28th March, 2015. So how can I manage display date among the different time zone? 但是它应该显示为本地日期,即2015年3月28日。那么,如何管理不同时区之间的显示日期?

Any idea or suggestions will be appreciated. 任何想法或建议,将不胜感激。

Well, one solution would be to create a column in your Database with the real timestamp of the date, time included. 好的,一种解决方案是在数据库中创建一个包含日期和时间的真实时间戳记的列。 So, you could show this date (reformated if you want) to client and keep the GMT +00.00 for the process part. 因此,您可以向客户显示此日期(如果需要,可以对其进行重新格式化),并使流程部件的格林尼治标准时间+00.00。

The problem here, if think is that since you don't save the time part, it's impossible to say if it was Day/Night. 这里的问题是,如果您想不到的是,由于您不节省时间,那么就无法确定是否为昼/夜。

The other solution would be to change your actual date to datetime and save it in GMT +00.00 with another column specifying the offset between GMT +00.00 region and the other (here, USA). 另一种解决方案是将您的实际日期更改为datetime,并将其保存在GMT +00.00中,并在另一列中指定GMT +00.00区域与另一个区域(此处是美国)之间的偏移量。

Some maths should do. 一些数学应该做。

I can't propose a written solution since you don't specify your server language (unless it's Javascript ?). 由于您未指定服务器语言(除非是Javascript,),所以我无法提出书面解决方案。

By all means, good luck with that ;). 无论如何,祝您好运;)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM