TimeZoneInfo in .NET Core when hosting on unix (nginx)

后端 未结 5 730
半阙折子戏
半阙折子戏 2020-12-09 07:55

For example, when I try to do the following.

TimeZoneInfo.FindSystemTimeZoneById(\"Central European Standard Time\")

I get the error, that

5条回答
  •  执念已碎
    2020-12-09 08:06

    If you want to try a Windows time zone and then fallback on a IANA one if the Windows one doesn't exist:

    var tzi  = TimeZoneInfo.GetSystemTimeZones().Any(x => x.Id == "Eastern Standard Time") ? 
        TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time") : 
        TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
    

提交回复
热议问题