TimeZoneInfo.ConvertTime converts a time to the time in a particular time zone.
Imports System
Imports Microsoft.VisualBasic
Module Example
Public Sub Main()
Dim times() As Date = { #1/1/2010 12:01AM#, _
DateTime.SpecifyKind(#1/1/2010 12:01AM#, DateTimeKind.Utc), _
DateTime.SpecifyKind(#1/1/2010 12:01AM#, DateTimeKind.Local)}
Dim est As TimeZoneInfo
est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")
Console.WriteLine("Local time zone: {0}", TimeZoneInfo.Local.DisplayName)
For Each timeToConvert As Date In times
Dim targetTime As Date = TimeZoneInfo.ConvertTime(timeToConvert, est)
Console.WriteLine("Converted {0} {1} to {2}.", timeToConvert, _
timeToConvert.Kind, targetTime)
Next
End Sub
End Module
Related examples in the same category