Returns the Coordinated Universal Time (UTC) that corresponds to a specified time.
using System;
using System.Globalization;
class DaylightTimeDemo
{
static void Main()
{
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = new DateTime(2001, 1, 1);
Console.WriteLine("Local time: {0}", localZone.StandardName);
DaylightTime daylight2001 = localZone.GetDaylightChanges(2001);
DaylightTime daylight2002 = localZone.GetDaylightChanges(2002);
DateTime utcTime = localZone.ToUniversalTime(localTime);
Console.WriteLine(localTime);
Console.WriteLine(TimeZone.IsDaylightSavingTime(localTime, daylight2001));
Console.WriteLine(TimeZone.IsDaylightSavingTime(localTime, daylight2002));
}
}
Related examples in the same category