How do I enumerate all time zones in .NET?

前端 未结 4 1076
长发绾君心
长发绾君心 2020-12-05 02:58

I would like to have a list of all the time zones available on a Windows Machine. How can I do this in .NET?

I know about the TimeZoneInfo.GetSystemTimeZones method

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 03:20

    Your code works fine for me. Here's the output on my box:

    You might be in the following time zones: (GMT) Casablanca (GMT)
    Greenwich Mean Time : Dublin,
    Edinburgh, Lisbon, London (GMT)
    Monrovia, Reykjavik

    That's all the ones with the same offset at the moment, which is what your code clearly displays - if you want all the timezones, just remove the "if" part, as Robert says.

    If you think you should be seeing more zones, could you tell us which timezone you're in so we can work out what other ones should be displayed?

提交回复
热议问题