C# Converting Time between TimeZones in C#

.Net 3.5 has introduced a new TimeZoneInfo class which is an improvement over the existing TimeZone class. The TimeZone class can work on local TimeZone only i.e. converting between UTC and Local time zone only. The new TimeZoneInfo class provide much more richer functionality of working with different other Time zone’s.

Here is an example of converting the local time to a time in different Time Zone like of Brisbane, Queensland in Australia.

DateTime qldTime =
    TimeZoneInfo.ConvertTimeBySystemTimeZoneId
    (
       DateTime.Now, TimeZoneInfo.Local.Id, "E. Australia Standard Time"
    );

Have fun.

Tags: ,

Leave a Reply