Converts a time from one time zone to another based on time zone identifiers.
using System;
public class Example
{
public static void Main()
{
DateTime currentTime = DateTime.Now;
Console.WriteLine("Current Times:");
Console.WriteLine("Los Angeles: {0}", TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Pacific Standard Time"));
Console.WriteLine("Beijing: {0}", TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "China Standard Time"));
Console.WriteLine("Tokyo: {0}", TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Tokyo Standard Time"));
}
}
Related examples in the same category