Share via


Date and Time: SYSTEMTIME Support

 

The latest version of this topic can be found at Date and Time: SYSTEMTIME Support.

The CTime class has constructors that accept system and file times from Win32. If you use CTime objects for these purposes, you must modify their initialization accordingly, as described in this article.

For information about the SYSTEMTIME structure, see SYSTEMTIME. For information about the FILETIME structure, see FILETIME.

MFC still provides CTime constructors that take time arguments in the MS-DOS style, but, starting in MFC version 3.0, the CTime class also supports a constructor that takes a Win32 SYSTEMTIME structure and another that takes a Win32 FILETIME structure.

The new CTime constructors are:

  • CTime(const SYSTEMTIME& sysTime);

  • CTime(const FILETIME& fileTime);

The fileTime parameter is a reference to a Win32 FILETIME structure, which represents time as a 64-bit value, a more convenient format for internal storage than a SYSTEMTIME structure and the format used by Win32 to represent the time of file creation.

If your code contains a CTime object initialized with the system time, you should use the SYSTEMTIME constructor in Win32.

You most likely will not use CTime FILETIME initialization directly. If you use a CFile object to manipulate a file, CFile::GetStatus retrieves the file timestamp for you via a CTime object initialized with a FILETIME structure.

What do you want to know more about

See Also

Date and Time