DateTime.FromFileTimeUtc() Method in C#


The DateTime.FromFileTimeUtc() method in C# converts the specified Windows file time to an equivalent UTC time.

Syntax

Following is the syntax −

public static DateTime FromFileTimeUtc (long time);

Here, the parameter time is the Windows file time expressed in ticks (expressed in 100-nanosecond ticks.)

Example

Let us now see an example to implement the DateTime.FromFileTimeUtc() method −

using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTimeUtc(6500000000000);
      System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
   }
}

Output

This will produce the following output −

DateTime = 08 January 1601, 12:33:20

Example

Let us now see another example to implement the DateTime.FromFileTimeUtc() method −

using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTimeUtc(0);
      DateTime d2 = DateTime.FromFileTimeUtc(850000000000000);
      Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
      Console.WriteLine("New DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d2);
   }
}

Output

This will produce the following output −

DateTime = 01 January 1601, 12:00:00
New DateTime = 11 September 1603, 07:06:40

Updated on: 07-Nov-2019

127 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements