Home »
C#
C# | DateTime.ToFileTimeUtc() Method with Example
DateTime.ToFileTimeUtc() Method: Here, we are going to learn about the ToFileTimeUtc() method of DateTime class with example in C#.
By IncludeHelp Last updated : August 27, 2023
C# DateTime.ToFileTimeUtc() Method
DateTime.ToFileTimeUtc() method is used to convert the current DateTime object into Windows file time.
Syntax
long DateTime.ToFileTimeUtc();
Parameter(s)
- It does not accept any parameter.
Return value
The return type of this method is long – it returns a long integer value that represents the windows file time.
Example to demonstrate example of DateTime.ToFileTimeUtc() method
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//creating an object of DateTime class
//and, initializing it with the current time
//using "Now"
DateTime dt = DateTime.Now;
//converting to windows file time from current date time
long time = dt.ToFileTimeUtc();
//printing the current date & time
Console.WriteLine("The current time is: " + dt.ToString());
//printing time in windows file time
Console.WriteLine("Windows file time: " + time);
//just to print a new line
Console.WriteLine();
}
}
}
Output
RUN 1:
The current time is: 10/17/2019 1:17:21 PM
Windows file time: 132157918412997330
RUN 2:
The current time is: 10/17/2019 1:17:45 PM
Windows file time: 132157918652078310
If we run program multiple times, the output will be different.