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);
   }
}

Output

This will produce the following output −

DateTimeOffset = 01 January 1601, 12:00:20

Updated on: 21-Apr-2020

33 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements