How to represent the current UK time?

前端 未结 5 1828
暗喜
暗喜 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:16

    I realize the question is for C#, but if all you want to do is a single conversion you can do this from the PowerShell command line:

    $d = [DateTime]::Parse("04/02/2014 17:00:00")
    $gmt = [TimeZoneInfo]::FindSystemTimeZoneById("GMT Standard Time");
    [TimeZoneInfo]::ConvertTime($d, $gmt, [TimeZoneInfo]::Local)
    

    This script would convert 17:00 UK time into your local time zone. For me, that would be CST. It's interesting to note that if I had set the date to 03/27/2014, the result would be different because the UK daylight saving time kicks in on different dates that the US.

提交回复
热议问题