Title: List timezones in C#
This simple example uses the following code to display the defined timezones.
// Load the timezone information.
private void Form1_Load(object sender, EventArgs e)
{
foreach (TimeZoneInfo info in TimeZoneInfo.GetSystemTimeZones())
lstTimezones.Items.Add(info);
}
This code simply loops through the TimeZoneInfo objects returned by TimeZoneInfo.GetSystemTimeZones and adds them to a ListBox. Those objects' ToString methods display the timezones' offsets from GMT and their locations, so that's what appears in the ListBox.
Download the example to experiment with it and to see additional details.
|