Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Displays the current date and time

#include <iostream> using std::cout; #include <ctime> using std::time_t; using std::time; using std::localtime; using std::asctime; int main() {    time_t currentTime;        time( &currentTime );        cout << asctime( localtime( &currentTime ) );    return 0; } Sun Apr 29 10:56:45 2007