Time zone ID
In this chapter you will learn:
Get Time zone ID
Get a TimeZoneInfo by calling FindSystemTimeZoneById with the zone ID.
using System;/* j a v a 2 s .c om*/
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
TimeZoneInfo wa = TimeZoneInfo.FindSystemTimeZoneById("W. Australia Standard Time");
Console.WriteLine(wa.Id);
Console.WriteLine(wa.DisplayName);
Console.WriteLine(wa.BaseUtcOffset);
Console.WriteLine(wa.SupportsDaylightSavingTime);
}
}
The output:
All Time zones
GetSystemTimeZones
method returns all world time zones.
You can list all valid zone ID strings as follows:
using System;/*from j a v a 2s. c o m*/
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
Console.WriteLine(z.Id);
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Date, Time, TimeZone