O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.9. Convert Dates and Times Across Time Zones

Problem

You need to work with dates and times in different time zones and be able to convert between them.

Solution

Use one of the conversion methods (ConvertTime, ConvertTimeBySystemTimeZoneId, ConvertTimeFromUtc, or ConvertTimeToUtc) of the new TimeZoneInfo class.

How It Works

Previous versions of .NET included the TimeZone class, which was used to represent a world time zone for a given date and time. Although this was useful, the class was severely limited because it was able to represent only the local time zone. Furthermore, conversions were limited to the local time zone and UTC.

The .NET Framework 3.5 introduces the NotInheritable TimeZoneInfo class, which adds important functionality that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required