.NET 3.5: How to Convert from one TimeZone to another
Jun 23, 2007 • C#The ability to convert directly from one timezone to another is coming (finally!) in .NET 3.5 via the addition of the System.TimeZoneInfo object.
Example C# Code:
DateTime oldTime = new DateTime(2007, 6, 23, 10, 0, 0);
TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);
Related Posts
-
C#: Case-Insensitive String Contains Best Practices
18 Oct 2024 -
C#: Read Text and JSON File Contents into Variable in Memory
18 Jun 2024 -
How to Cast an Int to an Enum in C#
17 Jun 2024