获取系统的时间,如下:
bool getCurrentTime(string &strSysTime)
{
time_t ltime;
struct tm *ltm;
time(<ime);
ltm = localtime(<ime);
char strdate[64],strtime[64];
sprintf(strdate,"%u/%02u/%02u",ltm->tm_year+1900,++ltm->tm_mon,ltm->tm_mday);
sprintf(strtime," %02u:%02u:%02u",ltm->tm_hour,ltm->tm_min,ltm->tm_sec);
string sd = strdate;
string st = strtime;
strSysTime= sd + st;
return true;
}