开发者

ASP.NET Javascript DateTime TimeZone Issues

I am having an issues passing a JSON containing DateTime to asp.net code-behind (c#).

If the client browser is in the same timezone as the server I have no issue,开发者_JAVA百科 but if they are in different timezones my time is getting modified by the offset value of the two timezones.

But all my datetimes need to be the date with a time of 00:00, regardless of the time zone this datetime comes from.

Thanks


If you want the client and the server to share the same relative time like that, have the client pass back a string describing the date in some easy-to-parse format. Then your server code can parse that string as if it's local time.

Alternatively you could have everything work in UTC time.

You have to be careful with things like this of course. For example, if the client is expecting to schedule some activity to take place at the server, then the server's midnight may not be the same as the midnight at the client. The client therefore needs to make it clear that the time setting is for the server's time zone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜