Is there a cross-platform way to get the current date and time in C++?
Why was ctime only mentioned in the comments so far?
#include #include int main() { std::time_t result = std::time(nullptr); std::cout << std::ctime(&result); }
Output
Tue Dec 27 17:21:29 2011