// Online documentation for the library functions in this // sample can be found here: // http://pubs.opengroup.org/onlinepubs/009695399/mindex.html #include <ctime> #include <iostream> using namespace std; // A simple example -- how to obtain current system // date and time. It prints today's date. int main() { time_t now = time( 0 ); // get system time struct tm tms; tms = *localtime( &now ); // convert to date/time components cout << ctime( &now ); // system call to extract printable date/time // Access individual date components and display them on the screen: cout << tms.tm_mon + 1; // month is zero based cout << "/"; cout << tms.tm_mday; cout << "/"; cout << tms.tm_year + 1900; // year is since 1900 cout << "\n"; return 0; }