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#.
Submitted by IncludeHelp, on October 18, 2019

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.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.