How to represent the current UK time?

前端 未结 5 1867
暗喜
暗喜 2021-01-02 02:37

I\'m facing an issue while converting dates between my server and client where both is running in Germany. The Regional settings on the client machines could be set to both

5条回答
  •  醉话见心
    2021-01-02 03:29

    The better approach to deal with local times is store them in unified representation such as UTC.

    So you can convert all input times to UTC (via .ToUniversalTime()), and store (or transmit) its value. When you need to show it just convert back by using .ToLocalTime().

    So you avoid rquirements to know which time zone was original value and can easily show stored value in different timezones.

    Also you can avoid incoming troubles where you have to write specific logic for processing time in next timezone trying to figure out how to convert them amongs all available.

提交回复
热议问题