我应该将什么值传递给TimeZoneInfo.FindSystemTimeZoneById(String)?

时间:2022-09-10 23:27:05

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

我想使用TimeZoneInfo.FindSystemTimeZoneById(String)方法,但是我不知道应该使用什么值作为输入?

Where can I get a list of values for id required for FindSystemTimeZoneById?

在哪里可以获得FindSystemTimeZoneById所需的id的值列表?

7 个解决方案

#1


64  

Here is the list in Windows 8 (I extracted from Windows Registry)

这是Windows 8中的列表(我从Windows Registry中提取)

Afghanistan Standard Time
Alaskan Standard Time
Alaskan Standard Time\Dynamic DST
Arab Standard Time
Ar* Standard Time
Arabic Standard Time
Arabic Standard Time\Dynamic DST
Argentina Standard Time
Argentina Standard Time\Dynamic DST
Atlantic Standard Time
Atlantic Standard Time\Dynamic DST
AUS Central Standard Time
AUS Eastern Standard Time
AUS Eastern Standard Time\Dynamic DST
Azerbaijan Standard Time
Azores Standard Time
Azores Standard Time\Dynamic DST
Bahia Standard Time
Bahia Standard Time\Dynamic DST
Bangladesh Standard Time
Bangladesh Standard Time\Dynamic DST
Canada Central Standard Time
Cape Verde Standard Time
Caucasus Standard Time
Caucasus Standard Time\Dynamic DST
Cen. Australia Standard Time
Cen. Australia Standard Time\Dynamic DST
Central America Standard Time
Central Asia Standard Time
Central Brazilian Standard Time
Central Brazilian Standard Time\Dynamic DST
Central Europe Standard Time
Central European Standard Time
Central Pacific Standard Time
Central Standard Time
Central Standard Time\Dynamic DST
Central Standard Time (Mexico)
China Standard Time
Dateline Standard Time
E. Africa Standard Time
E. Australia Standard Time
E. Europe Standard Time
E. South America Standard Time
E. South America Standard Time\Dynamic DST
Eastern Standard Time
Eastern Standard Time\Dynamic DST
Egypt Standard Time
Egypt Standard Time\Dynamic DST
Ekaterinburg Standard Time
Ekaterinburg Standard Time\Dynamic DST
Fiji Standard Time
Fiji Standard Time\Dynamic DST
FLE Standard Time
Georgian Standard Time
GMT Standard Time
Greenland Standard Time
Greenland Standard Time\Dynamic DST
Greenwich Standard Time
GTB Standard Time
Hawaiian Standard Time
India Standard Time
Iran Standard Time
Iran Standard Time\Dynamic DST
Israel Standard Time
Israel Standard Time\Dynamic DST
Jordan Standard Time
Jordan Standard Time\Dynamic DST
Kaliningrad Standard Time
Kaliningrad Standard Time\Dynamic DST
Kamchatka Standard Time
Korea Standard Time
Libya Standard Time
Libya Standard Time\Dynamic DST
Magadan Standard Time
Magadan Standard Time\Dynamic DST
Mauritius Standard Time
Mauritius Standard Time\Dynamic DST
Mid-Atlantic Standard Time
Middle East Standard Time
Middle East Standard Time\Dynamic DST
Montevideo Standard Time
Montevideo Standard Time\Dynamic DST
Morocco Standard Time
Morocco Standard Time\Dynamic DST
Mountain Standard Time
Mountain Standard Time\Dynamic DST
Mountain Standard Time (Mexico)
Myanmar Standard Time
N. Central Asia Standard Time
N. Central Asia Standard Time\Dynamic DST
Namibia Standard Time
Namibia Standard Time\Dynamic DST
Nepal Standard Time
New Zealand Standard Time
New Zealand Standard Time\Dynamic DST
Newfoundland Standard Time
Newfoundland Standard Time\Dynamic DST
North Asia East Standard Time
North Asia East Standard Time\Dynamic DST
North Asia Standard Time
North Asia Standard Time\Dynamic DST
Pacific SA Standard Time
Pacific SA Standard Time\Dynamic DST
Pacific Standard Time
Pacific Standard Time\Dynamic DST
Pacific Standard Time (Mexico)
Pakistan Standard Time
Pakistan Standard Time\Dynamic DST
Paraguay Standard Time
Paraguay Standard Time\Dynamic DST
Romance Standard Time
Russian Standard Time
Russian Standard Time\Dynamic DST
SA Eastern Standard Time
SA Pacific Standard Time
SA Western Standard Time
Samoa Standard Time
Samoa Standard Time\Dynamic DST
SE Asia Standard Time
Singapore Standard Time
South Africa Standard Time
Sri Lanka Standard Time
Syria Standard Time
Syria Standard Time\Dynamic DST
Taipei Standard Time
Tasmania Standard Time
Tasmania Standard Time\Dynamic DST
Tokyo Standard Time
Tonga Standard Time
Turkey Standard Time
Turkey Standard Time\Dynamic DST
Ulaanbaatar Standard Time
US Eastern Standard Time
US Eastern Standard Time\Dynamic DST
US Mountain Standard Time
UTC
UTC+12
UTC-02
UTC-11
Venezuela Standard Time
Venezuela Standard Time\Dynamic DST
Vladivostok Standard Time
Vladivostok Standard Time\Dynamic DST
W. Australia Standard Time
W. Australia Standard Time\Dynamic DST
W. Central Africa Standard Time
W. Europe Standard Time
West Asia Standard Time
West Pacific Standard Time
Yakutsk Standard Time
Yakutsk Standard Time\Dynamic DST

#2


26  

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

您可以从TimeZoneInfo类中的静态列表中获取它们

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

或者如果你只是想要一个时区id的列表,就像DJ KRAZE建议的那样

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

#3


7  

Have a look at the static method on TimeZoneInfo called TimeZoneInfo.GetSystemTimeZones() method.

查看TimeZoneInfo. getsystemtimezones()方法中的静态方法。

This will return a list of all TimeZoneInfo's on your operating system from the Registry. They are all stored under: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.

这将从注册表返回操作系统上的所有TimeZoneInfo的列表。它们都存储在:HKEY_LOCAL_MACHINE\软件\Microsoft\Windows NT\CurrentVersion\时区。

An example is "GMT Standard Time" for the "Dublin, Edinburgh, Lisbon, London" time zone.

例如“都柏林、爱丁堡、里斯本、伦敦”时区的“格林尼治标准时间”。

#4


6  

The available timezones are:

可用的时区是:

Console.WriteLine(string.Join("\n",TimeZoneInfo.GetSystemTimeZones().Select(x=>x.Id)));

Result:

结果:

Dateline Standard Time
UTC-11
Aleutian Standard Time
Hawaiian Standard Time
Marquesas Standard Time
Alaskan Standard Time
UTC-09
Pacific Standard Time (Mexico)
UTC-08
Pacific Standard Time
US Mountain Standard Time
Mountain Standard Time (Mexico)
Mountain Standard Time
Central America Standard Time
Central Standard Time
Easter Island Standard Time
Central Standard Time (Mexico)
Canada Central Standard Time
SA Pacific Standard Time
Eastern Standard Time (Mexico)
Eastern Standard Time
Haiti Standard Time
Cuba Standard Time
US Eastern Standard Time
Paraguay Standard Time
Atlantic Standard Time
Venezuela Standard Time
Central Brazilian Standard Time
SA Western Standard Time
Pacific SA Standard Time
Turks And Caicos Standard Time
Newfoundland Standard Time
Tocantins Standard Time
E. South America Standard Time
SA Eastern Standard Time
Argentina Standard Time
Greenland Standard Time
Montevideo Standard Time
Saint Pierre Standard Time
Bahia Standard Time
UTC-02
Mid-Atlantic Standard Time
Azores Standard Time
Cape Verde Standard Time
UTC
Morocco Standard Time
GMT Standard Time
Greenwich Standard Time
W. Europe Standard Time
Central Europe Standard Time
Romance Standard Time
Central European Standard Time
W. Central Africa Standard Time
Namibia Standard Time
Jordan Standard Time
GTB Standard Time
Middle East Standard Time
Egypt Standard Time
E. Europe Standard Time
Syria Standard Time
West Bank Standard Time
South Africa Standard Time
FLE Standard Time
Israel Standard Time
Kaliningrad Standard Time
Libya Standard Time
Arabic Standard Time
Turkey Standard Time
Arab Standard Time
Belarus Standard Time
Russian Standard Time
E. Africa Standard Time
Iran Standard Time
Ar* Standard Time
Astrakhan Standard Time
Azerbaijan Standard Time
Russia Time Zone 3
Mauritius Standard Time
Georgian Standard Time
Caucasus Standard Time
Afghanistan Standard Time
West Asia Standard Time
Ekaterinburg Standard Time
Pakistan Standard Time
India Standard Time
Sri Lanka Standard Time
Nepal Standard Time
Central Asia Standard Time
Bangladesh Standard Time
Omsk Standard Time
Myanmar Standard Time
SE Asia Standard Time
Altai Standard Time
W. * Standard Time
North Asia Standard Time
N. Central Asia Standard Time
Tomsk Standard Time
China Standard Time
North Asia East Standard Time
Singapore Standard Time
W. Australia Standard Time
Taipei Standard Time
Ulaanbaatar Standard Time
North Korea Standard Time
Aus Central W. Standard Time
Transbaikal Standard Time
Tokyo Standard Time
Korea Standard Time
Yakutsk Standard Time
Cen. Australia Standard Time
AUS Central Standard Time
E. Australia Standard Time
AUS Eastern Standard Time
West Pacific Standard Time
Tasmania Standard Time
Vladivostok Standard Time
Lord Howe Standard Time
Bougainville Standard Time
Russia Time Zone 10
Magadan Standard Time
Norfolk Standard Time
Sakhalin Standard Time
Central Pacific Standard Time
Russia Time Zone 11
New Zealand Standard Time
UTC+12
Fiji Standard Time
Kamchatka Standard Time
Chatham Islands Standard Time
Tonga Standard Time
Samoa Standard Time
Line Islands Standard Time

#5


2  

A complete list can be found on the MSDN website:

在MSDN网站上可以找到完整的列表:

Time Zone IDs (Compact 2013)

时区id(紧凑2013)

#6


1  

Like others have said, you can find the list by iterating TimeZoneInfo.GetSystemTimeZones() to find the string you want to use. That said, if you only have information on the time difference (like GMT+9 or GMT-10 ) and cannot find your timezone after iterating the Timezones, you might want to see the following url to see which timezone do you need https://msdn.microsoft.com/en-US/library/ms912391(v=winembedded.11).aspx

正如其他人所说,您可以通过迭代TimeZoneInfo.GetSystemTimeZones()来找到您想要使用的字符串。也就是说,如果您只有关于时差的信息(比如GMT+9或GMT-10),并且在迭代时区之后无法找到时区,您可能希望看到以下url,以查看需要https://msdn.microsoft.com/en-US/library/ms912391(v=winembedded.11).aspx的时区

#7


1  

Or you can pass the TimeZoneInfo.Local.Id like this:

或者你也可以通过timezone . local。Id是这样的:

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneInfo.Local.Id);
DateTime localDateTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tzi);

#1


64  

Here is the list in Windows 8 (I extracted from Windows Registry)

这是Windows 8中的列表(我从Windows Registry中提取)

Afghanistan Standard Time
Alaskan Standard Time
Alaskan Standard Time\Dynamic DST
Arab Standard Time
Ar* Standard Time
Arabic Standard Time
Arabic Standard Time\Dynamic DST
Argentina Standard Time
Argentina Standard Time\Dynamic DST
Atlantic Standard Time
Atlantic Standard Time\Dynamic DST
AUS Central Standard Time
AUS Eastern Standard Time
AUS Eastern Standard Time\Dynamic DST
Azerbaijan Standard Time
Azores Standard Time
Azores Standard Time\Dynamic DST
Bahia Standard Time
Bahia Standard Time\Dynamic DST
Bangladesh Standard Time
Bangladesh Standard Time\Dynamic DST
Canada Central Standard Time
Cape Verde Standard Time
Caucasus Standard Time
Caucasus Standard Time\Dynamic DST
Cen. Australia Standard Time
Cen. Australia Standard Time\Dynamic DST
Central America Standard Time
Central Asia Standard Time
Central Brazilian Standard Time
Central Brazilian Standard Time\Dynamic DST
Central Europe Standard Time
Central European Standard Time
Central Pacific Standard Time
Central Standard Time
Central Standard Time\Dynamic DST
Central Standard Time (Mexico)
China Standard Time
Dateline Standard Time
E. Africa Standard Time
E. Australia Standard Time
E. Europe Standard Time
E. South America Standard Time
E. South America Standard Time\Dynamic DST
Eastern Standard Time
Eastern Standard Time\Dynamic DST
Egypt Standard Time
Egypt Standard Time\Dynamic DST
Ekaterinburg Standard Time
Ekaterinburg Standard Time\Dynamic DST
Fiji Standard Time
Fiji Standard Time\Dynamic DST
FLE Standard Time
Georgian Standard Time
GMT Standard Time
Greenland Standard Time
Greenland Standard Time\Dynamic DST
Greenwich Standard Time
GTB Standard Time
Hawaiian Standard Time
India Standard Time
Iran Standard Time
Iran Standard Time\Dynamic DST
Israel Standard Time
Israel Standard Time\Dynamic DST
Jordan Standard Time
Jordan Standard Time\Dynamic DST
Kaliningrad Standard Time
Kaliningrad Standard Time\Dynamic DST
Kamchatka Standard Time
Korea Standard Time
Libya Standard Time
Libya Standard Time\Dynamic DST
Magadan Standard Time
Magadan Standard Time\Dynamic DST
Mauritius Standard Time
Mauritius Standard Time\Dynamic DST
Mid-Atlantic Standard Time
Middle East Standard Time
Middle East Standard Time\Dynamic DST
Montevideo Standard Time
Montevideo Standard Time\Dynamic DST
Morocco Standard Time
Morocco Standard Time\Dynamic DST
Mountain Standard Time
Mountain Standard Time\Dynamic DST
Mountain Standard Time (Mexico)
Myanmar Standard Time
N. Central Asia Standard Time
N. Central Asia Standard Time\Dynamic DST
Namibia Standard Time
Namibia Standard Time\Dynamic DST
Nepal Standard Time
New Zealand Standard Time
New Zealand Standard Time\Dynamic DST
Newfoundland Standard Time
Newfoundland Standard Time\Dynamic DST
North Asia East Standard Time
North Asia East Standard Time\Dynamic DST
North Asia Standard Time
North Asia Standard Time\Dynamic DST
Pacific SA Standard Time
Pacific SA Standard Time\Dynamic DST
Pacific Standard Time
Pacific Standard Time\Dynamic DST
Pacific Standard Time (Mexico)
Pakistan Standard Time
Pakistan Standard Time\Dynamic DST
Paraguay Standard Time
Paraguay Standard Time\Dynamic DST
Romance Standard Time
Russian Standard Time
Russian Standard Time\Dynamic DST
SA Eastern Standard Time
SA Pacific Standard Time
SA Western Standard Time
Samoa Standard Time
Samoa Standard Time\Dynamic DST
SE Asia Standard Time
Singapore Standard Time
South Africa Standard Time
Sri Lanka Standard Time
Syria Standard Time
Syria Standard Time\Dynamic DST
Taipei Standard Time
Tasmania Standard Time
Tasmania Standard Time\Dynamic DST
Tokyo Standard Time
Tonga Standard Time
Turkey Standard Time
Turkey Standard Time\Dynamic DST
Ulaanbaatar Standard Time
US Eastern Standard Time
US Eastern Standard Time\Dynamic DST
US Mountain Standard Time
UTC
UTC+12
UTC-02
UTC-11
Venezuela Standard Time
Venezuela Standard Time\Dynamic DST
Vladivostok Standard Time
Vladivostok Standard Time\Dynamic DST
W. Australia Standard Time
W. Australia Standard Time\Dynamic DST
W. Central Africa Standard Time
W. Europe Standard Time
West Asia Standard Time
West Pacific Standard Time
Yakutsk Standard Time
Yakutsk Standard Time\Dynamic DST

#2


26  

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

您可以从TimeZoneInfo类中的静态列表中获取它们

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

或者如果你只是想要一个时区id的列表,就像DJ KRAZE建议的那样

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

#3


7  

Have a look at the static method on TimeZoneInfo called TimeZoneInfo.GetSystemTimeZones() method.

查看TimeZoneInfo. getsystemtimezones()方法中的静态方法。

This will return a list of all TimeZoneInfo's on your operating system from the Registry. They are all stored under: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.

这将从注册表返回操作系统上的所有TimeZoneInfo的列表。它们都存储在:HKEY_LOCAL_MACHINE\软件\Microsoft\Windows NT\CurrentVersion\时区。

An example is "GMT Standard Time" for the "Dublin, Edinburgh, Lisbon, London" time zone.

例如“都柏林、爱丁堡、里斯本、伦敦”时区的“格林尼治标准时间”。

#4


6  

The available timezones are:

可用的时区是:

Console.WriteLine(string.Join("\n",TimeZoneInfo.GetSystemTimeZones().Select(x=>x.Id)));

Result:

结果:

Dateline Standard Time
UTC-11
Aleutian Standard Time
Hawaiian Standard Time
Marquesas Standard Time
Alaskan Standard Time
UTC-09
Pacific Standard Time (Mexico)
UTC-08
Pacific Standard Time
US Mountain Standard Time
Mountain Standard Time (Mexico)
Mountain Standard Time
Central America Standard Time
Central Standard Time
Easter Island Standard Time
Central Standard Time (Mexico)
Canada Central Standard Time
SA Pacific Standard Time
Eastern Standard Time (Mexico)
Eastern Standard Time
Haiti Standard Time
Cuba Standard Time
US Eastern Standard Time
Paraguay Standard Time
Atlantic Standard Time
Venezuela Standard Time
Central Brazilian Standard Time
SA Western Standard Time
Pacific SA Standard Time
Turks And Caicos Standard Time
Newfoundland Standard Time
Tocantins Standard Time
E. South America Standard Time
SA Eastern Standard Time
Argentina Standard Time
Greenland Standard Time
Montevideo Standard Time
Saint Pierre Standard Time
Bahia Standard Time
UTC-02
Mid-Atlantic Standard Time
Azores Standard Time
Cape Verde Standard Time
UTC
Morocco Standard Time
GMT Standard Time
Greenwich Standard Time
W. Europe Standard Time
Central Europe Standard Time
Romance Standard Time
Central European Standard Time
W. Central Africa Standard Time
Namibia Standard Time
Jordan Standard Time
GTB Standard Time
Middle East Standard Time
Egypt Standard Time
E. Europe Standard Time
Syria Standard Time
West Bank Standard Time
South Africa Standard Time
FLE Standard Time
Israel Standard Time
Kaliningrad Standard Time
Libya Standard Time
Arabic Standard Time
Turkey Standard Time
Arab Standard Time
Belarus Standard Time
Russian Standard Time
E. Africa Standard Time
Iran Standard Time
Ar* Standard Time
Astrakhan Standard Time
Azerbaijan Standard Time
Russia Time Zone 3
Mauritius Standard Time
Georgian Standard Time
Caucasus Standard Time
Afghanistan Standard Time
West Asia Standard Time
Ekaterinburg Standard Time
Pakistan Standard Time
India Standard Time
Sri Lanka Standard Time
Nepal Standard Time
Central Asia Standard Time
Bangladesh Standard Time
Omsk Standard Time
Myanmar Standard Time
SE Asia Standard Time
Altai Standard Time
W. * Standard Time
North Asia Standard Time
N. Central Asia Standard Time
Tomsk Standard Time
China Standard Time
North Asia East Standard Time
Singapore Standard Time
W. Australia Standard Time
Taipei Standard Time
Ulaanbaatar Standard Time
North Korea Standard Time
Aus Central W. Standard Time
Transbaikal Standard Time
Tokyo Standard Time
Korea Standard Time
Yakutsk Standard Time
Cen. Australia Standard Time
AUS Central Standard Time
E. Australia Standard Time
AUS Eastern Standard Time
West Pacific Standard Time
Tasmania Standard Time
Vladivostok Standard Time
Lord Howe Standard Time
Bougainville Standard Time
Russia Time Zone 10
Magadan Standard Time
Norfolk Standard Time
Sakhalin Standard Time
Central Pacific Standard Time
Russia Time Zone 11
New Zealand Standard Time
UTC+12
Fiji Standard Time
Kamchatka Standard Time
Chatham Islands Standard Time
Tonga Standard Time
Samoa Standard Time
Line Islands Standard Time

#5


2  

A complete list can be found on the MSDN website:

在MSDN网站上可以找到完整的列表:

Time Zone IDs (Compact 2013)

时区id(紧凑2013)

#6


1  

Like others have said, you can find the list by iterating TimeZoneInfo.GetSystemTimeZones() to find the string you want to use. That said, if you only have information on the time difference (like GMT+9 or GMT-10 ) and cannot find your timezone after iterating the Timezones, you might want to see the following url to see which timezone do you need https://msdn.microsoft.com/en-US/library/ms912391(v=winembedded.11).aspx

正如其他人所说,您可以通过迭代TimeZoneInfo.GetSystemTimeZones()来找到您想要使用的字符串。也就是说,如果您只有关于时差的信息(比如GMT+9或GMT-10),并且在迭代时区之后无法找到时区,您可能希望看到以下url,以查看需要https://msdn.microsoft.com/en-US/library/ms912391(v=winembedded.11).aspx的时区

#7


1  

Or you can pass the TimeZoneInfo.Local.Id like this:

或者你也可以通过timezone . local。Id是这样的:

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneInfo.Local.Id);
DateTime localDateTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tzi);