Skip to content

Instantly share code, notes, and snippets.

@autch
Created November 29, 2021 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autch/02e74d84f185a717ddfcecf2a6883e4c to your computer and use it in GitHub Desktop.
Save autch/02e74d84f185a717ddfcecf2a6883e4c to your computer and use it in GitHub Desktop.
Get FILETIME (Windows) value as of 1970-01-01T00:00:00Z
#include <windows.h>
#include <stdio.h>
int main()
{
SYSTEMTIME st;
FILETIME ft;
ULARGE_INTEGER ulft;
// 1970-01-01T00:00:00Z
st.wYear = 1970;
st.wMonth = 1;
st.wDayOfWeek = 4;
st.wDay = 1;
st.wHour = 0;
st.wMinute = 0;
st.wSecond = 0;
st.wMilliseconds = 0;
if(!SystemTimeToFileTime(&st, &ft))
{
fprintf(stderr, "SystemTimeToFileTime() failed, GLE=%d\n", GetLastError());
return 1;
}
ulft.HighPart = ft.dwHighDateTime;
ulft.LowPart = ft.dwLowDateTime;
printf("%llu", ulft.QuadPart);
return 0;
}
@autch
Copy link
Author

autch commented Dec 7, 2021

116444736000000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment