The LocalFileTimeToFileTime function converts a local file time to a file time based on the Coordinated Universal Time (UTC).
BOOL LocalFileTimeToFileTime( const FILETIME * lpLocalFileTime, FILETIME * lpFileTime )
TRUE if success, FALSE if error
EX1
int LocalFileTimeToFileTime_ex1() { WIN32_FILE_ATTRIBUTE_DATA fileInfo; string strFile = "c:\\test.txt"; BOOL bRet = FALSE; if(!strFile.IsFile()) { HANDLE hFile = CreateFile(strFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); } } if(GetFileAttributesEx(strFile, 0, &fileInfo)) { FILETIME localFiletime; if(LocalFileTimeToFileTime(&fileInfo.ftLastWriteTime, &localFiletime)) { SYSTEMTIME sysTime; if(FileTimeToSystemTime(&localFiletime, &sysTime)) { printf("Based on UTC time,%s is last modified at %.2d-%.2d-%4d %.2d:%.2d:%.2d\n", strFile, sysTime.wMonth,sysTime.wDay,sysTime.wYear, sysTime.wHour, sysTime.wMinute, sysTime.wSecond); return 1; } } } return 0; }
origin.h