C++ Get UTC date time of file creationdate

227 Views Asked by At

Hey I'm having trouble coding the following: I want to get the creationdate of a file by processid and I did it like so:

TCHAR Buffer[MAX_PATH];
if (GetModuleFileNameEx(Handle, 0, Buffer, MAX_PATH))
{
    std::string strx(Buffer);
    struct stat attrib;        
    stat(Buffer, &attrib); 
    std::wstring wsTmp(s.begin(), s.end());

    time_t creationdate = attrib.st_ctime; //outputs the localtime of the creationdate
}

this works great but however based on the timezone you live in the time changes. in utc+1 the creation time is like 12:00 and in utc+2 the creation time is 13:00.

I want to code it that the creationtime will always be utc so if you check it in utc+2 it will give me 11:00 instead of 13:00. and in utc-2 it also gives me 11:00 instead of 9:00.

Thanks for anyones help :)

0

There are 0 best solutions below