Get date creation of a file or time stamp

I been trying to get date of creation of a file in android but no success so far i had try this to methods but no one is working, anyone knows another way?


2.-auto lastModifiedTime = std::filesystem::last_write_time(ofToDataPath(“Scripts/”));

the second one should work fine, what problem do you have?

Code run’s but i’m getting this values:

how are you printing it? last_write_time returns file_time_type: which you can compare with other times… but probably just prints a number unless you convert it to a readable format. the reference for the function above also has an example on how to print it as a human readable format

Gotcha, i’m printing using ofLog() maybe that’s why

 std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
    std::cout << "File write time is " << std::asctime(std::localtime(&cftime)) << '\n';

I guess is this part without local time but when i write the code it say’s that can’t resolve clock container

Hi Arturo coudn’t really get the code to work any hint?


This worked for me in macOS

auto currentLocale = std::filesystem::last_write_time(ofToDataPath(“Scripts/” + filename.get()));
std::tm * ptm = std::localtime(&currentLocale);
char buffer[32];
// Format: Mo, 15.06.2009 20:20:00
std::strftime(buffer, 32, “%a, %d.%m.%Y %H:%M:%S”, ptm);

I have found it in:
Assuming that the file_time_type can be casted to std::time_t.

Don’t know if it will work on android

1 Like

Cool! it worked on android.