Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Time
Using Time
 Converting a time_t Value to a File...
Converting a time_t Value to a File Time

The time functions included in the C run-time use the time_t type to represent the number of seconds elapsed since midnight, January 1, 1970. The following example converts a time_t value to a file time, using the Int32x32To64 function.

C++
#include <windows.h>
#include <time.h>

void TimetToFileTime( time_t t, LPFILETIME pft )
{
    LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
    pft->dwLowDateTime = (DWORD) ll;
    pft->dwHighDateTime = ll >>32;
}

After you have obtained a file time, you can convert this value to system time using the FileTimeToSystemTime function.

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
UInt32x32To64 instead?      Jonxboy01   |   Edit   |   Show History
shouldn't that code use "UInt32x32To64" (Unsigned) ? It seems that there could be issues if the high bit is set on a or b.
Tags What's this?: Add a tag
Flag as ContentBug
This procedure is required even though time_t is now __int64      Vikram K   |   Edit   |   Show History
I checked with Visual Studio 2008, the above conversion is still applicable.
Tags What's this?: Add a tag
Flag as ContentBug
time_t is Now 64-bit      Jon Baggott   |   Edit   |   Show History
This page is no longer correct. Since Visual Studio 2005, time_t is (by default) a 64-bit integer so Int32x32To64 can't be used.
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker