- 论坛徽章:
- 0
|
//YYYYMMDDhhmiss
string now(){
long clock;
struct tm* tm;
int year=0,month=0,day=0,hour=0,minute=0,second=0;
char szDateTime[14+1];
memset(szDateTime,'\0',sizeof(szDateTime));
time ( &clock );
tm = localtime ( &clock );
year = (tm->tm_year > 80) ? (tm->tm_year + 1900) : (tm->tm_year + 2000);
month = tm->tm_mon + 1;
day = tm->tm_mday;
hour = tm->tm_hour;
minute = tm->tm_min;
second = tm->tm_sec;
sprintf(szDateTime,"%04d%02d%02d%02d%02d%02d",year,month,day,hour,minute,second);
return string(szDateTime);
} |
|