Gets a TimeZoneInfo object that represents the local time zone.
using System;
public class Example
{
public static void Main()
{
DateTime date1 = new DateTime(2010, 3, 21, 2, 0, 0);
Console.WriteLine(date1.ToUniversalTime());
Console.WriteLine(TimeZoneInfo.ConvertTimeToUtc(date1));
Console.WriteLine(TimeZoneInfo.ConvertTimeToUtc(date1, TimeZoneInfo.Local));
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
Console.WriteLine(TimeZoneInfo.ConvertTimeToUtc(date1, tz));
}
}
Related examples in the same category