[Solved] Create a folder with the creation time as prefix (C++) [closed]


First you need to get the date and time:

std::time_t t = std::time(nullptr);
std::tm tm = *std::localtime(&t);

Then you need to format it to a style you want, I went for displaying day of the month and minute of the hour. See here for how to format it.

// format date and time
std::ostringstream date_and_time_ss;
date_and_time_ss << std::put_time(&tm, "Date%dTime%M");

Finally you need to create the directory:

std::filesystem::create_directory(date_and_time_ss.str() + "_Folder");

Example output on 12th of November at 7:00pm:
Date12Time00_Folder

solved Create a folder with the creation time as prefix (C++) [closed]