C# TimeZoneInfo GetSystemTimeZones

Description

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

Syntax

TimeZoneInfo.GetSystemTimeZones has the following syntax.


public static ReadOnlyCollection<TimeZoneInfo> GetSystemTimeZones()

Returns

TimeZoneInfo.GetSystemTimeZones method returns <

Example

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.


/*from w w  w  .  ja  v a 2  s.  com*/
using System;
using System.Globalization;
using System.IO;
using System.Collections.ObjectModel;

public class Example
{
   public static void Main()
   {

      DateTimeFormatInfo dateFormats = CultureInfo.CurrentCulture.DateTimeFormat;
      ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones(); 

      foreach (TimeZoneInfo timeZone in timeZones)
      {
         Console.WriteLine("Daylight Name: {0, 39}", timeZone.DaylightName);
      }
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version