I think there is a date class. Unlike Java, C ++ does not have this class, you can use the time. H function of the C library to obtain the current time, or call the DOS date
Method 1:
#include <iostream>#include <ctime>#include<string>using namespace std;int main (){ time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); cout<<"Current local time and date:"<< asctime (timeinfo)<<endl; system("pause"); return 0;}
Method 2:
#include<iostream>#include<ctime>#include<string>using namespace std;int main(){time_t lltime;time(lltime);cout<<"the time is "<<ctime(lltime)<<endl;system("pause");return 0;}
Method 3:
include <ctime>#include<string>using namespace std;#define CCT (+8)int main (){ time_t rawtime; struct tm * ptm; time ( &rawtime ); ptm = gmtime ( &rawtime ); cout<<"Beijing (China):"<<(ptm->tm_hour+CCT)%24<<":"<<ptm->tm_min<<endl; system("pause"); return 0;}
Method 4:
#include<iostream>#include<string>#include<vector>using namespace std;int main(){system("time");system("pause");return 0;}