TimeZoneInfo.ConvertTime converts a time to the time in a particular time zone. : TimeZoneInfo « Date Time « VB.Net






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

1.TimeZoneInfo.BaseUtcOffset gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).
2.TimeZoneInfo.ConvertTimeToUtc
3.TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")
4.TimeZoneInfo.DaylightName
5.TimeZoneInfo.DisplayName
6.TimeZoneInfo.Equals
7.TimeZoneInfo.IsDaylightSavingTime
8.Gets a TimeZoneInfo object that represents the local time zone.
9.Gets a TimeZoneInfo object that represents the Coordinated Universal Time (UTC) zone.
10.Display the names for standard time and daylight saving time for the local time zone
11.Display the current date and time and show if they occur in daylight saving time
12.Get the current Coordinated Universal Time (UTC) and UTC offset.
13.Display the daylight saving time range for the current year
14.Convert a time from one time zone to another.
15.Converts a time to the time in a particular time zone.
16.Converts a time from one time zone to another based on time zone identifiers.
17.Eastern Standard Time
18.GMT Standard Time
19.Russian Standard Time
20.India Standard Time
21.China Standard Time
22.Tokyo Standard Time
23.Converts a Coordinated Universal Time (UTC) to the time in a specified time zone.
24.Converts the current date and time to Coordinated Universal Time (UTC).
25.Converts the time in a specified time zone to Coordinated Universal Time (UTC).
26.Creates a time zone with identifier, an offset from Coordinated Universal Time (UTC), a display name, and a standard time display name.
27.Gets the time zone identifier.
28.whether a date and time is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times.
29.Report time as DST if it is either ambiguous or DST
30.Gets a value indicating whether the time zone has any daylight saving time rules.