TimeZone.GetUtcOffset 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( "Local time: {0}" , localZone.StandardName )
Dim loopX As Integer
For loopX = 0 to 10
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 )
Next loopX
End Sub
End Module
Related examples in the same category