DateTimeOffset.FromFileTime() Method in C#


The DateTimeOffset.FromFileTime() method in C# is used to convert the specified Windows file time to an equivalent local time.

Syntax

Following is the syntax −

public static DateTimeOffset FromFileTime (long time);

Above, time is the Windows file time, in ticks.

Example

Let us now see an example to implement the DateTimeOffset.FromFileTime() method −

using System;
public class Demo {
   public static void Main() {
      DateTimeOffset offset = DateTimeOffset.FromFileTime(0);
      Console.WriteLine("DateTimeOffset = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset);
   }
}

Output

This will produce the following output −

DateTimeOffset = 01 January 1601, 12:00:00

Example

Let us now see another example to implement the DateTimeOffset.FromFileTime() method −

using System;
public class Demo {
   public static void Main() {
      DateTimeOffset offset = DateTimeOffset.FromFileTime(200000000);
      Console.WriteLine("DateTimeOffset = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset);
   }
}

This will produce the following output −

DateTimeOffset = 01 January 1601, 12:00:20
raja
Published on 06-Nov-2019 06:50:49
Advertisements