DateTime.Now and Culture/Timezone specific

后端 未结 5 1631
你的背包
你的背包 2020-12-07 17:00

Our application was designed to handle user from different Geographic location.

We are unable to detect what is the current end user local time and

5条回答
  •  一整个雨季
    2020-12-07 17:31

    We faced a similar problem with an application I worked on recently. During development every one was in the same time zone and the issue wasn't noticed. And in any case there was a lot of legacy code that would have been a pain to change not to mention converting all the date time info that was already in the DB. So changing to DateTimeOffset was not an option. But we managed to get it all consistent by converting from server time to user time on the way out and converting from user time to server time on the way in. It was also important to do this with any date time comparisons that were a boundary. So if a user expected some thing to expire midnight their time then we would convert that time to server time and do all comparisons in server time. This sounds like a lot of work but was much less work then converting the entire application and DB to use DateTimeOffsets.

    Hear is a thread that looks like has some good solutions to the time zone issue.

    Determine a User's Timezone

提交回复
热议问题