TimeZone.GetUtcOffset Method returns the Coordinated Universal Time (UTC) offset for the specified local time. : TimeZone « Date Time « VB.Net






TimeZone.GetUtcOffset Method returns the Coordinated Universal Time (UTC) offset for the specified local time.

 

Imports System
Imports Microsoft.VisualBasic

Module UTCTimeDemo
    Sub Main( )
        Dim localZone As TimeZone = TimeZone.CurrentTimeZone
        Dim baseUTC As DateTime = new DateTime( 2000, 1, 1 )

        Console.WriteLine(localZone.StandardName )

        Dim localTime As DateTime = localZone.ToLocalTime( baseUTC )
        Dim localOffset As TimeSpan = localZone.GetUtcOffset( localTime )

        Console.WriteLine( "{0,-20:yyyy-MM-dd HH:mm}" & _
                "{1,-20:yyyy-MM-dd HH:mm}{2,-12}{3}", _
                baseUTC, localTime, localOffset, _
                localZone.IsDaylightSavingTime( localTime ) )

        baseUTC = baseUTC.AddDays( 155.55 )
    End Sub 
End Module 

   
  








Related examples in the same category

1.TimeZone.GetDaylightChanges returns the daylight saving time period for a particular year.
2.TimeZone.GetUtcOffset returns the Coordinated Universal Time (UTC) offset for the specified local time.
3.TimeZone.IsDaylightSavingTime
4.TimeZone.ToLocalTime returns the local time that corresponds to a specified date and time value.