C# DateTime.ToFileTimeUtc() Method with Example

DateTime.ToFileTimeUtc() Method: Here, we will find out about the ToFileTimeUtc() technique for DateTime class with example in C#.

DateTime.ToFileTimeUtc() Method

DateTime.ToFileTimeUtc() strategy is utilized to change over the current DateTime object into Windows document time.

Syntax:

long DateTime.ToFileTimeUtc();

Parameter(s):

  • It doesn’t acknowledge any parameter.

Return value:

The arrival kind of this technique is long – it restores a long integer value that speaks to the windows document time.

Example to exhibit an example of DateTime.ToFileTimeUtc() technique

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

On the off chance that we run program on various occasions, the output will be different.

Leave a Comment

error: Alert: Content is protected!!