C++ 获取系统时间
#include <iostream>
#include <time.h>
using namespace std;
int main(int arg,char* args[])
{
time_t now2;
time(&now2);
struct tm* fmt2=localtime(&now2);.
cout << "小时:\t" << fmt2->tm_hour << endl;
cout << "分钟:\t" << fmt2->tm_min << endl;
cout << "秒数:\t" << fmt2->tm_sec << endl;
cout << "秒数:\t" << fmt2->tm_sec << endl;
cout << "年是:\t" << fmt2->tm_year +1900<< endl;
cout << "月是:\t" << fmt2->tm_mon+1<< endl;
cout << "日是:\t" << fmt2->tm_mday<< endl;
return 0;
}
浙公网安备 33010602011771号