Home >Backend Development >C++ >How Can I Get a Complete List of Time Zone IDs for Use with C#'s `FindTimeZoneById()`?

How Can I Get a Complete List of Time Zone IDs for Use with C#'s `FindTimeZoneById()`?

Susan Sarandon
Susan SarandonOriginal
2025-01-13 15:41:43165browse

How Can I Get a Complete List of Time Zone IDs for Use with C#'s `FindTimeZoneById()`?

C# FindTimeZoneById() List of time zone IDs used by the method

Introduction:

When dealing with time zones in C#, the TimeZoneInfo class provides a convenient way to access and manipulate time zone information. The FindTimeZoneById() method allows you to retrieve a TimeZoneInfo object for a specific time zone by its identifier. However, finding the complete list of all supported time zone identifiers can be challenging.

Access time zone ID list:

To get a complete list of time zone IDs, use the TimeZoneInfo method of the GetSystemTimeZones() class. This method returns a IEnumerable<TimeZoneInfo> collection containing all time zones supported by the operating system.

Code example:

The following code snippet demonstrates how to print a list of all time zone IDs using the GetSystemTimeZones() method:

<code class="language-csharp">using System;

namespace TimeZoneIds
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
            {
                Console.WriteLine(z.Id);
            }
        }
    }
}</code>

Result:

When run on a Windows 7 workstation, the above code outputs the following list of time zone IDs:

<code>Dateline Standard Time
UTC-11
Samoa Standard Time
Hawaiian Standard Time
Alaskan Standard Time
Pacific Standard Time (Mexico)
Pacific Standard Time
US Mountain Standard Time
Mountain Standard Time (Mexico)
Mountain Standard Time
Central America Standard Time
Central Standard Time
Central Standard Time (Mexico)
Canada Central Standard Time
SA Pacific Standard Time
Eastern Standard Time
US Eastern Standard Time
Venezuela Standard Time
Paraguay Standard Time
Atlantic Standard Time
Central Brazilian Standard Time
SA Western Standard Time
Pacific SA Standard Time
Newfoundland Standard Time
E. South America Standard Time
Argentina Standard Time
SA Eastern Standard Time
Greenland Standard Time
Montevideo Standard Time
UTC-02
Mid-Atlantic Standard Time
Azores Standard Time
Cape Verde Standard Time
Morocco Standard Time
UTC
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
Syria Standard Time
South Africa Standard Time
FLE Standard Time
Israel Standard Time
E. Europe Standard Time
Arabic Standard Time
Arab Standard Time
Russian Standard Time
E. Africa Standard Time
Iran Standard Time
Arabian Standard Time
Azerbaijan Standard Time
Mauritius Standard Time
Georgian Standard Time
Caucasus Standard Time
Afghanistan Standard Time
Ekaterinburg Standard Time
Pakistan Standard Time
West Asia Standard Time
India Standard Time
Sri Lanka Standard Time
Nepal Standard Time
Central Asia Standard Time
Bangladesh Standard Time
N. Central Asia Standard Time
Myanmar Standard Time
SE Asia Standard Time
North Asia Standard Time
China Standard Time
North Asia East Standard Time
Singapore Standard Time
W. Australia Standard Time
Taipei Standard Time
Ulaanbaatar 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
Central Pacific Standard Time
New Zealand Standard Time
UTC+12
Fiji Standard Time
Kamchatka Standard Time
Tonga Standard Time</code>

Additional notes:

The list of supported time zone IDs may vary depending on the operating system and its updates. To ensure access to the most up-to-date list, consider using a library or online resource that maintains a complete database of time zone identifiers.

The above is the detailed content of How Can I Get a Complete List of Time Zone IDs for Use with C#'s `FindTimeZoneById()`?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn