clance
asked on
Convert date/time to FILETIME
Is there a Win32 or MFC function that converts a local timestamp specified as year, month, day, hour, minute, second to a local time FILETIME structure?
CTime will accept a FILETIME and will give you back year, month, day, hour, minute, second. And you can construct a CTime by specifying year, month, day, hour, minute, second, but it will not return a FILETIME.
SystemTimeToFileTime() does this conversion, but it assumes SYSTEMTIME is UTC and FILETIME is local, so it also does timezone conversion, but in the wrong direction for my need. There's also a SystemTimeToTzSpecificLoca lTime() function, but again it's converting the UTC to local. I could use this if there was a function to convert local to UTC.
CTime will accept a FILETIME and will give you back year, month, day, hour, minute, second. And you can construct a CTime by specifying year, month, day, hour, minute, second, but it will not return a FILETIME.
SystemTimeToFileTime() does this conversion, but it assumes SYSTEMTIME is UTC and FILETIME is local, so it also does timezone conversion, but in the wrong direction for my need. There's also a SystemTimeToTzSpecificLoca
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I swear I accepted your answer before, but I guess it didn't get processed. Your solution worked, but in a very different way than I thought.
Essentually, what AfxTimeToFileTime() does is take the local time and converts it to the opposite direction of UTC, but then it makes the opposite conversion again leaving it result back to local time. It works, but for all the wrong reasons.
Thanks