How to convert CTime to integer?

823 Views Asked by At

I need to get modify date from a file.

    CFileStatus stat;
    CFile::GetStatus(strFilePath, stat);

It returns 1585557924 to be CTime. (it look like a timestamp)

    stat.m_mtime

I have a lot of file and I need to get modify date from each file as timestamp then sum all timestamp.

But It cannot convert stat.m_mtime to integer.

   int sum_timestamp = 0;
   sum_timestamp +=  (int)stat.m_mtime;

It error like these.

   'no suitable conversion function from "ATL::CTime"to"int"exists'
1

There are 1 best solutions below

0
Kiruahxh On

Assuming you are compiling in 64 bits, you can get a unix timestamp from CTime using GetTime(), which is is a __time64_t_ (= __int64 = long long). Ex:

   long long sum_timestamp = 0;
   sum_timestamp += stat.m_mtime.GetTime();