What value should I pass into TimeZoneInfo.FindSystemTimeZoneById(String)?

前端 未结 10 1983
南笙
南笙 2020-12-04 15:22

I want to use the TimeZoneInfo.FindSystemTimeZoneById(String) method, but I don\'t know what values to use as the input?

Where can I get a list of values for i

10条回答
  •  猫巷女王i
    2020-12-04 15:29

    You can fetch them from a static list in the TimeZoneInfo class

    var infos = TimeZoneInfo.GetSystemTimeZones();
    foreach (var info in infos)
    {
        Console.WriteLine(info.Id);
    }
    

    Example:

      var tzInfo = TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time");
    

    Or if you just want a list of the timezone id's like DJ KRAZE suggested

      var timeZoneIds = TimeZoneInfo.GetSystemTimeZones().Select(t => t.Id);
    

提交回复
热议问题