1#include <iostream>
2#include <ctime>
3
4using namespace std;
5
6int main() {
7 // current date/time based on current system
8 time_t now = time(0);
9
10 cout << "Number of sec since January 1,1970 is:: " << now << endl;
11
12 tm *ltm = localtime(&now);
13
14 // print various components of tm structure.
15 cout << "Year:" << 1900 + ltm->tm_year<<endl;
16 cout << "Month: "<< 1 + ltm->tm_mon<< endl;
17 cout << "Day: "<< ltm->tm_mday << endl;
18 cout << "Time: "<< 5+ltm->tm_hour << ":";
19 cout << 30+ltm->tm_min << ":";
20 cout << ltm->tm_sec << endl;
21}