I finally found the answer. In this article, we explain TimeZoneInfo and TimeZone in detail, and there are some examples of converting time at different times.
All you need to know is the identifier of the time zone in which you want to convert.
Example (taken from the site):
DateTimeOffset nowDateTime = DateTimeOffset.Now; DateTimeOffset newDateTime = TimeZoneInfo.ConvertTime( nowDateTime, TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time")); Console.WriteLine("Now: {0}", nowDateTime); Console.WriteLine("Now in Hawaii: {0}", newDateTime);
prints
Now: 3/5/2011 6:30:48 PM -08:00
Now in Hawaii: 3/5/2011 4:30:48 PM -10:00
To get a list of all identifiers, you can:
- Check
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones - Request
TimeZoneInfo.GetSystemTimeZones();
source share