using System;
using System.Text;
class Sample
{
public static void Main()
{
TimeZone zone = TimeZone.CurrentTimeZone;
DateTime dt1 = new DateTime(2008, 1, 1);
Console.WriteLine(zone.GetUtcOffset(dt1));
}
}
The output:
-08:00:00
TimeZoneInfo GetUtcOffset method accepts either a DateTime or a DateTimeOffset.
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
TimeZoneInfo zone = TimeZoneInfo.Local;
DateTime dt1 = new DateTime(2008, 1, 1);
Console.WriteLine(zone.GetUtcOffset(dt1));
DateTime dtf = new DateTime(2008, 1, 1);
Console.WriteLine(zone.GetUtcOffset(dtf));
}
}
The output:
-08:00:00
-08:00:00
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |