#include<iostream>
#include<iomanip>
#include<ctime>usingnamespacestd;intmain(){inttm_sec,tm_min,tm_hour,tm_mday,tm_mon,tm_wday,tm_yday,counter=0;time_tt;time(&t);tm*ltm=localtime(&t);cout<<"———————————————————————————————————————————";cout<<"\nProgram to print the current date & time\n";cout<<"———————————————————————————————————————————\n";cout<<"Date "<<setw(11)<<"| "<<(ltm->tm_mday)<<"/"<<(ltm->tm_mon)+1<<"/"<<(ltm->tm_year)+1900<<"\n";cout<<"Hours "<<setw(10)<<"| "<<ltm->tm_hour<<"\n";cout<<"Minutes "<<setw(8)<<"| "<<ltm->tm_min<<"\n";cout<<"Seconds "<<setw(8)<<"| "<<ltm->tm_sec<<"\n";cout<<"Year "<<setw(11)<<"| "<<1900+ltm->tm_year<<"\n";cout<<"Current Time "<<setw(3)<<"| "<<ltm->tm_hour<<":"<<ltm->tm_min<<":"<<ltm->tm_sec<<"\n";cout<<"Date Of Month "<<setw(1)<<"| "<<ltm->tm_mday<<"\n";cout<<"Current Month "<<setw(1)<<"| "<<1+ltm->tm_mon<<"\n";cout<<"Day Of Week "<<setw(4)<<"| "<<ltm->tm_wday<<"\n";cout<<"Days In Year "<<setw(3)<<"| "<<ltm->tm_yday<<"\n";cout<<"\n"<<ctime(&t);cout<<"———————————————————————————————————————————\n";return0;}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to print the current date & time
———————————————————————————————————————————
Date | 30/4/2019
Hours | 8
Minutes | 37
Seconds | 36
Year | 2019
Current Time | 8:37:36
Date Of Month | 30
Current Month | 4
Day Of Week | 2
Days In Year | 119
Tue Apr 30 08:37:36 2019
———————————————————————————————————————————
kodingwindow@kw:~$
Advertisement
Thank You
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?