Returns the Coordinated Universal Time (UTC) offset for the specified local time. : TimeZone « Date Time « C# / C Sharp






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

1.The IsDaylightSavingTime and GetUtcOffset methods work as follows:
2.The GetDaylightChanges method returns specific daylight saving information for a given year:
3.The static TimeZone.CurrentTimeZone method returns a TimeZone object based on the current local settings
4.TimeZone Info
5.Convert To TimeZone
6.Display the names for standard time and daylight saving time for the local time zone.
7.Display the current date and time and show if they occur in daylight saving time.
8.Get the current Coordinated Universal Time (UTC) and UTC offset.
9.Display the daylight saving time range for the current year.
10.Returns the daylight saving time period for a particular year.
11.Whether the specified date and time is within a daylight saving time period.
12.Get UTC offset
13.Returns the Coordinated Universal Time (UTC) that corresponds to a specified time.