List all the TimeZones available on your machine using C# or VB.NET

To list the different TimeZones on your machine, use the TimeZoneInfo class. Here’s a sample:

C#

static class Program
{
public static void Main(string[] args)
{
var tzone = TimeZoneInfo.GetSystemTimeZones();

foreach (TimeZoneInfo tzi in tzone)
{
Console.WriteLine("{0}", tzi.DisplayName);
}
Console.ReadLine();
}

}

VB.NET

Class Program
Private Sub New()
End Sub
Public Shared Sub
Main(ByVal args() As String)
Dim tzone = TimeZoneInfo.GetSystemTimeZones()

For Each tzi As TimeZoneInfo In tzone
Console.WriteLine("{0}", tzi.DisplayName)
Next tzi
Console.ReadLine()
End Sub

End Class

OUTPUT

image






About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

1 comment:

Anonymous said...

nice..