1

I need to get the timezone list. For that, I used this

var timezoneList = TimeZoneInfo.GetSystemTimeZones();

I found the index values for the timezone in this link https://support.microsoft.com/en-in/help/973627/microsoft-time-zone-index-values

How to get this index values?

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • 1
    It seems that TimeZoneInfo does not provide this information. –  Nov 01 '19 at 07:30
  • 2
    This has been asked [before](https://stackoverflow.com/questions/9896550/obtaining-the-windows-time-zone-index-when-using-timezoneinfo-getsystemtimezones) but there seems to be no solution other than implementing the mapping yourself. – Klaus Gütter Nov 01 '19 at 07:36
  • @KlausGütter - OK. Is there any other unique values are there in `TimeZoneInfo.GetSystemTimeZones()`? – Nivitha Gopalakrishnan Nov 01 '19 at 08:35

2 Answers2

1

That is a static list that is old and outdated. I will work to have it removed.

Microsoft does not currently publish the full list of time zones to a web page. Any such list would be a snapshot in time, and would need to be updated any time there was a new Windows time zone created.

To get the current list of time zones, you can use any of the following:

  • TimeZoneInfo.GetSystemTimeZones in .NET
  • EnumDynamicTimeZoneInformation in the Windows API
  • tzutil.exe /L on the Windows command line
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones in the Windows Registry

As to the "index value" - those values were created for the original Windows Embedded product line. They are not useful in modern applications, nor are they maintained in any way. Instead, you should use the string Id, as shown in Oliver's answer.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
0

You may create an array yourself like suggested by @KlausGütter with a Dictionary mapping your expected Ids with TimeZoneInfo.Id.

So you can create a Dictionary<string, long> and you copy/paste strings values matching hex values.

Example:

Dictionary<string, long> TimeZoneMapper = new Dictionary<string, long>()
{
  { "Dateline Standard Time", 0 },
  // ...
  { "Kamchatka Standard Time", 0x80000052 }
};

Usage:

long id = TimeZoneMapper[timeZoneInfo.Id];

Here are the properties that has TimeZoneInfo:

  • Id is a unique english short name.
  • DisplayName is a unique localized full name.

Example:

foreach ( var zone in TimeZoneInfo.GetSystemTimeZones() )
  Console.WriteLine($"{zone.Id} => {zone.DisplayName}");

Output:

Dateline Standard Time => (UTC-12:00) Ligne de date internationale (Ouest)
UTC-11 => (UTC-11:00) Temps universel coordonné-11
Hawaiian Standard Time => (UTC-10:00) Hawaii
Aleutian Standard Time => (UTC-10:00) Îles Aléoutiennes
Marquesas Standard Time => (UTC-09:30) Îles Marquises
Alaskan Standard Time => (UTC-09:00) Alaska
UTC-09 => (UTC-09:00) Temps universel coordonné-09
Pacific Standard Time (Mexico) => (UTC-08:00) Basse Californie
Pacific Standard Time => (UTC-08:00) Pacifique (É.-U. et Canada)
UTC-08 => (UTC-08:00) Temps universel coordonné-08
US Mountain Standard Time => (UTC-07:00) Arizona
Mountain Standard Time (Mexico) => (UTC-07:00) Chihuahua, La Paz, Mazatlan
Mountain Standard Time => (UTC-07:00) Montagnes Rocheuses (É.-U. et Canada)
Central America Standard Time => (UTC-06:00) Amérique centrale
Central Standard Time => (UTC-06:00) Centre (É.-U. et Canada)
Central Standard Time (Mexico) => (UTC-06:00) Guadalajara, Mexico, Monterrey
Canada Central Standard Time => (UTC-06:00) Saskatchewan
Easter Island Standard Time => (UTC-06:00) Île de Pâques
SA Pacific Standard Time => (UTC-05:00) Bogota, Lima, Quito, Rio Branco
Eastern Standard Time (Mexico) => (UTC-05:00) Chetumal
Eastern Standard Time => (UTC-05:00) Est (É.-U. et Canada)
Cuba Standard Time => (UTC-05:00) Havane (La)
Haiti Standard Time => (UTC-05:00) Haïti
US Eastern Standard Time => (UTC-05:00) Indiana (Est)
Turks And Caicos Standard Time => (UTC-05:00) Îles Turques-et-Caïques
Paraguay Standard Time => (UTC-04:00) Asunción
Venezuela Standard Time => (UTC-04:00) Caracas
Central Brazilian Standard Time => (UTC-04:00) Cuiaba
SA Western Standard Time => (UTC-04:00) Georgetown, La Paz, Manaus, San Juan
Atlantic Standard Time => (UTC-04:00) Heure Atlantique (Canada)
Pacific SA Standard Time => (UTC-04:00) Santiago
Newfoundland Standard Time => (UTC-03:30) Terre-Neuve-et-Labrador
Tocantins Standard Time => (UTC-03:00) Araguaína
E. South America Standard Time => (UTC-03:00) Brasilia
Argentina Standard Time => (UTC-03:00) Buenos Aires
SA Eastern Standard Time => (UTC-03:00) Cayenne, Fortaleza
Greenland Standard Time => (UTC-03:00) Groenland
Montevideo Standard Time => (UTC-03:00) Montevideo
Magallanes Standard Time => (UTC-03:00) Punta Arenas
Saint Pierre Standard Time => (UTC-03:00) Saint-Pierre-et-Miquelon
Bahia Standard Time => (UTC-03:00) Salvador
Mid-Atlantic Standard Time => (UTC-02:00) Centre-Atlantique - Ancien
UTC-02 => (UTC-02:00) Temps universel coordonné-02
Azores Standard Time => (UTC-01:00) Les Açores
Cape Verde Standard Time => (UTC-01:00) Îles du Cap-Vert
UTC => (UTC) Temps universel coordonné
GMT Standard Time => (UTC+00:00) Dublin, Édimbourg, Lisbonne, Londres
Greenwich Standard Time => (UTC+00:00) Monrovia, Reykjavik
Sao Tome Standard Time => (UTC+00:00) São Tomé
Morocco Standard Time => (UTC+01:00) Casablanca
W. Central Africa Standard Time => (UTC+01:00) Afrique centrale - Ouest
W. Europe Standard Time => (UTC+01:00) Amsterdam, Berlin, Berne, Rome, Stockholm, Vienne
Central Europe Standard Time => (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prag
Romance Standard Time => (UTC+01:00) Bruxelles, Copenhague, Madrid, Paris
Central European Standard Time => (UTC+01:00) Sarajevo, Skopje, Varsovie, Zagreb
Jordan Standard Time => (UTC+02:00) Amman
GTB Standard Time => (UTC+02:00) Athènes, Bucarest
Middle East Standard Time => (UTC+02:00) Beyrouth
E. Europe Standard Time => (UTC+02:00) Chisinau
Syria Standard Time => (UTC+02:00) Damas
West Bank Standard Time => (UTC+02:00) Gaza, Hébron
South Africa Standard Time => (UTC+02:00) Harare, Pretoria
FLE Standard Time => (UTC+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius
Israel Standard Time => (UTC+02:00) Jérusalem
Kaliningrad Standard Time => (UTC+02:00) Kaliningrad
Sudan Standard Time => (UTC+02:00) Khartoum
Egypt Standard Time => (UTC+02:00) Le Caire
Libya Standard Time => (UTC+02:00) Tripoli
Namibia Standard Time => (UTC+02:00) Windhoek
Arabic Standard Time => (UTC+03:00) Bagdad
Turkey Standard Time => (UTC+03:00) Istanbul
Arab Standard Time => (UTC+03:00) Koweït, Riyad
Belarus Standard Time => (UTC+03:00) Minsk
Russian Standard Time => (UTC+03:00) Moscou, Saint-Pétersbourg
E. Africa Standard Time => (UTC+03:00) Nairobi
Iran Standard Time => (UTC+03:30) Téhéran
Arabian Standard Time => (UTC+04:00) Abu Dhabi, Muscat
Astrakhan Standard Time => (UTC+04:00) Astrakhan, Oulianovsk
Azerbaijan Standard Time => (UTC+04:00) Bakou
Caucasus Standard Time => (UTC+04:00) Erevan
Russia Time Zone 3 => (UTC+04:00) Izhevsk, Samara
Mauritius Standard Time => (UTC+04:00) Port Louis
Saratov Standard Time => (UTC+04:00) Saratov
Georgian Standard Time => (UTC+04:00) Tbilissi
Volgograd Standard Time => (UTC+04:00) Volgograd
Afghanistan Standard Time => (UTC+04:30) Kaboul
West Asia Standard Time => (UTC+05:00) Achgabat, Tachkent
Ekaterinburg Standard Time => (UTC+05:00) Iekaterinbourg
Pakistan Standard Time => (UTC+05:00) Islamabad, Karachi
Qyzylorda Standard Time => (UTC+05:00) Kyzylorda
India Standard Time => (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
Sri Lanka Standard Time => (UTC+05:30) Sri Jayawardenepura
Nepal Standard Time => (UTC+05:45) Katmandou
Central Asia Standard Time => (UTC+06:00) Astana
Bangladesh Standard Time => (UTC+06:00) Dhaka
Omsk Standard Time => (UTC+06:00) Omsk
Myanmar Standard Time => (UTC+06:30) Rangoon
SE Asia Standard Time => (UTC+07:00) Bangkok, Hanoi, Djakarta
Altai Standard Time => (UTC+07:00) Barnaoul, Gorno-Altaïsk
W. Mongolia Standard Time => (UTC+07:00) Hovd
North Asia Standard Time => (UTC+07:00) Krasnoïarsk
N. Central Asia Standard Time => (UTC+07:00) Novosibirsk
Tomsk Standard Time => (UTC+07:00) Tomsk
China Standard Time => (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
North Asia East Standard Time => (UTC+08:00) Irkoutsk
Singapore Standard Time => (UTC+08:00) Kuala Lumpur, Singapour
Ulaanbaatar Standard Time => (UTC+08:00) Oulan-Bator
W. Australia Standard Time => (UTC+08:00) Perth
Taipei Standard Time => (UTC+08:00) Taipei
Aus Central W. Standard Time => (UTC+08:45) Eucla
Transbaikal Standard Time => (UTC+09:00) Chita
Yakutsk Standard Time => (UTC+09:00) Iakoutsk
Tokyo Standard Time => (UTC+09:00) Osaka, Sapporo, Tokyo
North Korea Standard Time => (UTC+09:00) Pyongyang
Korea Standard Time => (UTC+09:00) Séoul
Cen. Australia Standard Time => (UTC+09:30) Adélaïde
AUS Central Standard Time => (UTC+09:30) Darwin
E. Australia Standard Time => (UTC+10:00) Brisbane
AUS Eastern Standard Time => (UTC+10:00) Canberra, Melbourne, Sydney
West Pacific Standard Time => (UTC+10:00) Guam, Port Moresby
Tasmania Standard Time => (UTC+10:00) Hobart
Vladivostok Standard Time => (UTC+10:00) Vladivostok
Lord Howe Standard Time => (UTC+10:30) Île Lord Howe
Russia Time Zone 10 => (UTC+11:00) Chokurdakh
Magadan Standard Time => (UTC+11:00) Magadan
Sakhalin Standard Time => (UTC+11:00) Sakhaline
Bougainville Standard Time => (UTC+11:00) Île Bougainville
Norfolk Standard Time => (UTC+11:00) Île Norfolk
Central Pacific Standard Time => (UTC+11:00) Îles Salomon, Nouvelle-Calédonie
Russia Time Zone 11 => (UTC+12:00) Anadyr, Petropavlovsk-Kamtchatski
New Zealand Standard Time => (UTC+12:00) Auckland, Wellington
Fiji Standard Time => (UTC+12:00) Fidji
Kamchatka Standard Time => (UTC+12:00) Petropavlovsk-Kamchatsky - Ancien
UTC+12 => (UTC+12:00) Temps universel coordonné+12
Chatham Islands Standard Time => (UTC+12:45) Îles Chatham
Tonga Standard Time => (UTC+13:00) Nuku'alofa
Samoa Standard Time => (UTC+13:00) Samoa
UTC+13 => (UTC+13:00) Temps universel coordonné+13
Line Islands Standard Time => (UTC+14:00) Kiritimati, Île
  • 1
    Hi. Your answer is good, but just so you are aware - `TimeZoneInfo` already caches the list internally, so building a dictionary isn't necessarily going to do anything other than take time to create a copy. One can iterate `GetSystemTimeZones` as you showed, and one can look up a specific time zone using `FindSystemTimeZoneById`. Both will use that internal cache. – Matt Johnson-Pint Nov 01 '19 at 16:26