This documentation is archived and is not being maintained.

TimeZoneInfo.GetSystemTimeZones Method

Returns a sorted collection of all the time zones about which information is available on the local system.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static ReadOnlyCollection<TimeZoneInfo> GetSystemTimeZones()

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo>
A read-only collection of TimeZoneInfo objects.


There is insufficient memory to store all time zone information.


The user does not have permission to read from the registry keys that contain time zone information.

The GetSystemTimeZones method retrieves all available time zone information from the subkeys of the registry's HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zones key. If it is unable to successfully retrieve and parse values for particular string properties of individual TimeZoneInfo objects, this method sets their value to an empty string ("").

Important noteImportant

The GetSystemTimeZones method returns a collection of TimeZoneInfo objects only for time zones defined in the registry. It does not include time zones created using the overloads of the CreateCustomTimeZone method. These are accessible only through the object reference returned by the time zone creation method.

The collection returned by this method is sorted by display name using the current culture. For information about the display name, see DisplayName.

The ReadOnlyCollection<T> object returned by this method supports the IEnumerable<T> interface, which means that it can be iterated using the foreach (in C#) or For Each…Next (in Visual Basic) statements. Each iteration of the loop provides the next TimeZoneInfo object in the collection.

The collection of TimeZoneInfo objects represents time zones defined on the local computer; it does not necessarily provide complete information for all time zones during all time periods. If your application requires time zones not found on the local computer, you can create custom time zones using the overloads of the CreateCustomTimeZone method. For more information, see How to: Create Time Zones Without Adjustment Rules and How to: Create Time Zones with Adjustment Rules.

You can also determine whether an individual time zone is defined on the local computer by calling the FindSystemTimeZoneById method and providing the identifier of the time zone you want to retrieve as a parameter.

The following example retrieves a collection of time zone objects that represent the time zones defined on a computer and writes information about them to a text file.

using System;
using System.Globalization;
using System.IO;
using System.Collections.ObjectModel;

public class Example
   public static void Main()
      const string OUTPUTFILENAME = @"C:\Temp\TimeZoneInfo.txt";

      DateTimeFormatInfo dateFormats = CultureInfo.CurrentCulture.DateTimeFormat;
      ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones(); 
      StreamWriter sw = new StreamWriter(OUTPUTFILENAME, false);

      foreach (TimeZoneInfo timeZone in timeZones)
         bool hasDST = timeZone.SupportsDaylightSavingTime;
         TimeSpan offsetFromUtc = timeZone.BaseUtcOffset;
         TimeZoneInfo.AdjustmentRule[] adjustRules;
         string offsetString;

         sw.WriteLine("ID: {0}", timeZone.Id);
         sw.WriteLine("   Display Name: {0, 40}", timeZone.DisplayName);
         sw.WriteLine("   Standard Name: {0, 39}", timeZone.StandardName);
         sw.Write("   Daylight Name: {0, 39}", timeZone.DaylightName);
         sw.Write(hasDST ? "   ***Has " : "   ***Does Not Have ");
         sw.WriteLine("Daylight Saving Time***");
         offsetString = String.Format("{0} hours, {1} minutes", offsetFromUtc.Hours, offsetFromUtc.Minutes);
         sw.WriteLine("   Offset from UTC: {0, 40}", offsetString);
         adjustRules = timeZone.GetAdjustmentRules();
         sw.WriteLine("   Number of adjustment rules: {0, 26}", adjustRules.Length);  
         if (adjustRules.Length > 0)
            sw.WriteLine("   Adjustment Rules:");
            foreach (TimeZoneInfo.AdjustmentRule rule in adjustRules)
               TimeZoneInfo.TransitionTime transTimeStart = rule.DaylightTransitionStart;
               TimeZoneInfo.TransitionTime transTimeEnd = rule.DaylightTransitionEnd; 

               sw.WriteLine("      From {0} to {1}", rule.DateStart, rule.DateEnd);
               sw.WriteLine("      Delta: {0}", rule.DaylightDelta);
               if (! transTimeStart.IsFixedDateRule)
                  sw.WriteLine("      Begins at {0:t} on {1} of week {2} of {3}", transTimeStart.TimeOfDay, 
                                                                                dateFormats.MonthNames[transTimeStart.Month - 1]);
                  sw.WriteLine("      Ends at {0:t} on {1} of week {2} of {3}", transTimeEnd.TimeOfDay,
                                                                                dateFormats.MonthNames[transTimeEnd.Month - 1]);
                  sw.WriteLine("      Begins at {0:t} on {1} {2}", transTimeStart.TimeOfDay, 
                                                                 dateFormats.MonthNames[transTimeStart.Month - 1]);
                  sw.WriteLine("      Ends at {0:t} on {1} {2}", transTimeEnd.TimeOfDay, 
                                                               dateFormats.MonthNames[transTimeEnd.Month - 1]);

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.