Pages

Saturday, 23 April 2016

How to display a system date and time

#include <ctime>#include <iostream>
using namespace std; int main() {     time_t t = time(0); // get time now     struct tm * now = localtime( & t );
     cout << now->tm_mday << '-'//day     << (now->tm_mon +1 ) << '-'//month     << (now->tm_year +1900 )//year     <<endl     <<now->tm_hour//hour     <<'-'<<now->tm_min//min     <<'-'<< now->tm_sec//sec     << endl;
     return 0;}

No comments:

Post a Comment