How can convert Windows analog to unix time command?

Asked By 7060 points N/A Posted on -

want to know details about  converting windows analog to UNIX time command?

Answered By 0 points N/A #84836

How can convert Windows analog to unix time command?


Here is your conversion code. By using this code, you can convert Windows analog time to UNIX time.

#include <windows.h>
 * number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC
#define EPOCH_DIFF 11644473600LL
void gettimeofday(ULARGE_INTEGER* microsecondsAsULINT)
        FILETIME ftTime;
        SYSTEMTIME stTime;
       // Get the current system time
        // Convert it to filetime which is # of 100ns periods since Jan 1, 1601
        SystemTimeToFileTime(&stTime, &ftTime);
        // Move it into the return result
        microsecondsAsULINT->HighPart = ftTime.dwHighDateTime;
        microsecondsAsULINT->LowPart = ftTime.dwLowDateTime;
        // Convert to UTC by subtracting epoch difference as 100ns periods
        microsecondsAsULINT->QuadPart -= (EPOCH_DIFF*10000000);
        // Convert to microseconds ([# of 100ns periods]/10 = [# of 1us periods])
        microsecondsAsULINT->QuadPart = microsecondsAsULINT->QuadPart/10;

Login/Register to Answer

Related Questions