DateTimeOffset.Offset : DateTimeOffset « System « C# / C Sharp by API






DateTimeOffset.Offset

 
using System;
public class MainClass {
    public static void Main() {

        DateTimeOffset local = DateTimeOffset.Now;
        DateTimeOffset utc = local.ToUniversalTime();

        Console.WriteLine(local.Offset);   // -06:00:00 (in Central America)
        Console.WriteLine(utc.Offset);     // 00:00:00

        Console.WriteLine(local == utc);                 // True
        //To include the Offset in the comparison, you must use the EqualsExact method:
        Console.WriteLine(local.EqualsExact(utc));      // False
    }
}

   
  








Related examples in the same category