#include <iostream> #include <ctime> int main() { std::time_t now = std::time(0); std::tm* localTime = std::localtime(&now); char buf[80]; std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localTime); std::cout << "Formatted Date and Time: " << buf << std::endl; return 0; }