Sign in to follow this  
wood_brian

Converting FileTime to time_t on Windows

Recommended Posts

A FILETIME is the number of 100-nanosecond intervals since January 1, 1601.
A time_t is the number of 1-second intervals since January 1, 1970.

From there you can derive the following:


time_t filetime_to_timet(const FILETIME& ft)
{
ULARGE_INTEGER ull;
ull.LowPart = ft.LowPart;
ull.HighPart = ft.HighPart;

return ull.QuadPart / 10000000ULL - 11644473600ULL;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by cache_hit
A FILETIME is the number of 100-nanosecond intervals since January 1, 1601.
A time_t is the number of 1-second intervals since January 1, 1970.

From there you can derive the following:


time_t filetime_to_timet(const FILETIME& ft)
{
ULARGE_INTEGER ull;
ull.LowPart = ft.LowPart;
ull.HighPart = ft.HighPart;

return ull.QuadPart / 10000000ULL - 11644473600ULL;
}





Thanks for that. That seems to be working with two minor changes:


time_t
filetime_to_timet(FILETIME const& ft) const
{
ULARGE_INTEGER ull;
ull.LowPart = ft.dwLowDateTime;
ull.HighPart = ft.dwHighDateTime;
return ull.QuadPart / 10000000ULL - 11644473600ULL;
}


Brian Wood
http://webEbenezer.net
(651) 251-9384

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this