how to get the time in c++ as string
#include <iostream>
#include <ctime>
#include <iomanip>
int main() {
// Get the current time
std::time_t currentTime = std::time(nullptr);
// Convert the time to a string
std::tm* localTime = std::localtime(¤tTime);
std::stringstream timeStringStream;
timeStringStream << std::put_time(localTime, "%Y-%m-%d %H:%M:%S");
std::string timeString = timeStringStream.str();
// Display the time as a string
std::cout << "Current time: " << timeString << std::endl;
return 0;
}