Phương thức DateTime.FromFileTime() trong C# chuyển đổi thời gian file Windows được chỉ định thành thời gian địa phương tương đương.
Cú pháp
public static DateTime FromFileTime(long fileTime);
Tham số fileTime là thời gian file Windows tính bằng ticks.
Ví dụ 1
using System;
public class Demo
{
public static void Main()
{
DateTime d1 = DateTime.FromFileTime(100000000000);
System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
}
}
Đầu ra
DateTime = 01 January 1601, 02:46:40
Ví dụ 2
using System;
public class Demo
{
public static void Main()
{
DateTime d1 = DateTime.FromFileTime(0);
System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
}
}
Đầu ra
DateTime = 01 January 1601, 12:00:00