c 2b 2b date time

Solutions on MaxInterview for c 2b 2b date time by the best coders in the world

showing results for - "c 2b 2b date time"
Florencia
12 Apr 2020
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}