Returns the Coordinated Universal Time (UTC) offset for the specified local time.
using System;
class UTCTimeDemo
{
static void Main( )
{
const string headFmt = "{0,-20}{1,-20}{2,-12}{3}";
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime baseUTC = new DateTime( 2000, 1, 1 );
Console.WriteLine(localZone.StandardName );
for( int loopX = 0; loopX <= 10; loopX++ )
{
DateTime localTime = localZone.ToLocalTime( baseUTC );
TimeSpan localOffset = localZone.GetUtcOffset( localTime );
Console.WriteLine(baseUTC);
Console.WriteLine(localTime);
Console.WriteLine(localOffset);
Console.WriteLine(localZone.IsDaylightSavingTime( localTime ) );
baseUTC = baseUTC.AddDays( 155.55 );
}
}
}
Related examples in the same category