常用时间类型转换

1.time_t 转 FILETIME
FILETIME ft;
LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
ft.dwLowDateTime = (DWORD) ll;
ft.dwHighDateTime = (DWORD)(ll >> 32);

2.FILETIME 转 time_t
FILETIME ft;
LONGLONG llTime;
time_t t;
llTime = (ft.dwHighDateTime << 32) + ft.dwLowDateTime;

t = (DWORD)((LONGLONG)(llTime - 116444736000000000) / 10000000);

3.SYSTEMTIME 转 FILETIME
FILETIME ft;
SYSTEMTIME st;
SystemTimeToFileTime( &st, &ft );

4. FILETIME 转 SYSTEMTIME
FILETIME ft;
SYSTEMTIME st;
FileTimeToSystemTime( &ft, &st);

5.DATE 转 SYSTEMTIME
DATE pst;
SYSTEMTIME st;
VariantTimeToSystemTime(pst,&st);


6. SYSTEMTIME 转 DATE
DATE pst;
SYSTEMTIME st;

SystemTimeToVariantTime(&st, &pst);

 

你可能感兴趣的:(常用时间类型转换)