int main() { time_t nowTime; time(&nowTime);//获取当前时间(世界时间)//这种写法也一样nowTime=time(NULL) ; //如果要转化为本地时间struct tm *t=localtime(&nowTime);
long t=nowTime; cout<<t<<endl; char strTmptime[9]; sprintf(strTmptime,"%X",t);//十六进制输出 cout<<strTmptime<<endl; return 0; }