O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

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

System.TimeZone

The TimeZone class encapsulates information about time zones and provides conversion utilities between local time and UTC time. Listing B.17 provides an example using TimeZone (timezone.cs).

Listing B.17. TimeZone Example
 public class TimeZoneMain { static void Main(string [] args) { TimeZone tz = TimeZone.CurrentTimeZone; Console.WriteLine("{0} {1} ", tz.DaylightName, tz.StandardName); DaylightTime dt = tz.GetDaylightChanges(DateTime.Now.Year); Console.WriteLine("Start daylight savings time {0} ", dt.Start); Console.WriteLine("End daylight savings time {0} ", dt.End); Console.WriteLine("Daylight savings time change {0} ", dt.Delta); Console.WriteLine("Is daylight savings? {0} ", tz.IsDaylightSavingTime(DateTime.Now)); Console.WriteLine("UTC ...

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