Home »
.Net »
C# Programs
C# - TimeZoneInfo.GetSystemTimeZones() Method with Example
In this tutorial, we will learn about the C# TimeZoneInfo.GetSystemTimeZones() method with its definition, usage, syntax, and example.
By Nidhi Last updated : March 31, 2023
TimeZoneInfo.GetSystemTimeZones() Method
The TimeZoneInfo.GetSystemTimeZones() is a static method and used to get a sorted collection of all the time zones about which information is available on the local system.
Syntax
ReadOnlyCollection<TimeZoneInfo> TimeZoneInfo.GetSystemTimeZones();
Parameter(s)
Return Value
This method returns a sorted collection of all the time zones.
Exception(s)
- System.OutOfMemoryException
- System.Security.SecurityException
C# Example of TimeZoneInfo.GetSystemTimeZones() Method
The source code to get a sorted collection of all the time zones is given below. The given program is compiled and executed successfully.
using System;
using System.Globalization;
using System.Collections.ObjectModel;
class TimeZoneInfoDemo {
//Entry point of Program
static public void Main() {
//Create a collection to get list of time zone.
ReadOnlyCollection < TimeZoneInfo > listOfTimeZones;
listOfTimeZones = TimeZoneInfo.GetSystemTimeZones();
Console.WriteLine("\nList of Time Zone:");
foreach(TimeZoneInfo time_zone in listOfTimeZones) {
Console.WriteLine("{0, 39}", time_zone.DaylightName);
}
}
}
Output
List of Time Zone:
Dateline Daylight Time
Samoa Daylight Time
Hawaiian Daylight Time
Alaskan Daylight Time
Pacific Daylight Time
Pacific Daylight Time (Mexico)
US Mountain Daylight Time
Mountain Daylight Time (Mexico)
Mountain Daylight Time
Central America Daylight Time
Central Daylight Time
Central Daylight Time (Mexico)
Canada Central Daylight Time
SA Pacific Daylight Time
Eastern Daylight Time
US Eastern Daylight Time
Venezuela Daylight Time
Paraguay Daylight Time
Atlantic Daylight Time
SA Western Daylight Time
Central Brazilian Daylight Time
Pacific SA Daylight Time
Newfoundland Daylight Time
E. South America Daylight Time
Argentina Daylight Time
SA Eastern Daylight Time
Greenland Daylight Time
Montevideo Daylight Time
Mid-Atlantic Daylight Time
Azores Daylight Time
Cape Verde Daylight Time
Morocco Daylight Time
Coordinated Universal Time
GMT Daylight Time
Greenwich Daylight Time
W. Europe Daylight Time
Central Europe Daylight Time
Romance Daylight Time
Central European Daylight Time
W. Central Africa Daylight Time
Jordan Daylight Time
GTB Daylight Time
Middle East Daylight Time
Egypt Daylight Time
South Africa Daylight Time
FLE Daylight Time
Jerusalem Daylight Time
E. Europe Daylight Time
Namibia Daylight Time
Arabic Daylight Time
Arab Daylight Time
Russian Daylight Time
E. Africa Daylight Time
Georgian Daylight Time
Iran Daylight Time
Arabian Daylight Time
Azerbaijan Daylight Time
Mauritius Daylight Time
Caucasus Daylight Time
Afghanistan Daylight Time
Ekaterinburg Daylight Time
Pakistan Daylight Time
West Asia Daylight Time
India Daylight Time
Sri Lanka Daylight Time
Nepal Daylight Time
N. Central Asia Daylight Time
Central Asia Daylight Time
Myanmar Daylight Time
SE Asia Daylight Time
North Asia Daylight Time
China Daylight Time
North Asia East Daylight Time
Malay Peninsula Daylight Time
W. Australia Daylight Time
Taipei Daylight Time
Tokyo Daylight Time
Korea Daylight Time
Yakutsk Daylight Time
Cen. Australia Daylight Time
AUS Central Daylight Time
E. Australia Daylight Time
AUS Eastern Daylight Time
West Pacific Daylight Time
Tasmania Daylight Time
Vladivostok Daylight Time
Central Pacific Daylight Time
New Zealand Daylight Time
Fiji Daylight Time
Kamchatka Daylight Time
Tonga Daylight Time
Press any key to continue . . .
C# TimeZoneInfo Class Programs »