开发者

How to display the dates to the user based on the client timezone

Pl help me. I'm saving the date in UTC format. while displaying it, i'm converting it to local time. but it is displaying server time. How can i display the date by identifying t开发者_高级运维he client timezone?


I would venture a guess here that you are doing the conversion in C# code as part of an ASP.NET website.

Converting to local time converts to the local time of the machine where the code is actually executing. Thus, when you convert to local time, you are converting to the local timezone of your server machine, not the client machine.

To convert to the client local time, you need to know the local timezone of the client machine. Unfortunately, the standard ASP.NET HttpRequest does not include that information (mostly because the HTTP protocol does not specify a standard way for the client HTTP agent to pass its local timezone to the HTTP server). Multiple people have come with various solutions about this problem; here's one recent blog post about Handling TimeZone Information In ASP.NET that can help you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜