Article ID: 167296
Article Last Modified on 11/21/2006
#include <winbase.h>
#include <winnt.h>
#include <time.h>
void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
Once the UNIX time is converted to a FILETIME structure, other Win32 time
formats can be easily obtained by using Win32 functions such as
FileTimeToSystemTime() and FileTimeToDosDateTime().
void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
FILETIME ft;
UnixTimeToFileTime(t, &ft);
FileTimeToSystemTime(&ft, pst);
}
Additional query words: bse time tm filetime systemtime crt
Keywords: kbdatetime kbhowto kbkernbase kbprogramming KB167296