记录和打印时间
std::string get_timer()
{
char szTmp[64] = {0};
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm tmNow;
localtime_r(&tv.tv_sec, &tmNow);
strftime(szTmp,sizeof(szTmp), "[%Y-%m-%d %H:%M:%S]", &tmNow);
//strftime(szTmp,64,"%H:%M:%S",&ptm);
return temp;
}
原文
http://blog.csdn.net/maocl1983/article/details/6221810
http://www.cnblogs.com/mydomain/archive/2011/09/04/2166577.html