I am trying to figure out a way to convert a FILETIME
structure from UTC to Local and vice versa.
I've been using the two functions: FileTimetoLocalFileTime()
and LocalFileTimeToFileTime()
. The problem seems that they do not work as expected.
As an example: First I got a local file time using:
WIN32_FIND_DATA fd;
FindFirstFile(_T("Path:To:File"), &fd);
now fd has the last write date in local format.
Then I use LocalFileTimeToFileTime()
to convert the last write date to UTC and then convert that FILETIME structure to an 64bit integer as described in MSDN. http://support.microsoft.com/kb/188768
Then I store that number in a DB for later.
Now when I change the timezone for example, I get the 64bit integer from the DB. Convert it into a FILETIME
structure and then try to convert it to its local value. Using FileTimeToLocalFileTime()
. The problem is that when I compare that file time with the local time of the same file and of course making sure that no changes have been made to the file. The times are different. I am not sure why but its like that every time.
I Would开发者_运维问答 also like to know if there is a possible way to convert the FILETIME
as is to a readable string. Without using CTime or SYSTEMTIME
since both of them convert the FILETIME
to its UTC equivalent which I don't really want, as I would like to see the exact converted time from both functions LocalFileTimeToFileTime() and FileTimeToLocalFileTime().
Hope I've explained the situation, and hope someone would help me achieve my goal
精彩评论