Is there a cross-platform way to get the current date and time in C++?
You can also directly use ctime():
ctime()
#include #include int main () { time_t rawtime; struct tm * timeinfo; time ( &rawtime ); printf ( "Current local time and date: %s", ctime (&rawtime) ); return 0; }