Home › C++ Tutorial › C++ date and time
C++ date and time
ctime basics.
time(0) gives seconds since 1970. ctime converts it to readable text.
Example code
#include <iostream>
#include <ctime>
using namespace std;
int main() {
time_t now = time(0);
cout << ctime(&now);
return 0;
}