string getTimeString()
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
stringstream result;
result << setfill('0');
result << setw(4) << 1900+timeinfo->tm_year;
result << "_" << setw(2) << 1+timeinfo->tm_mon;
result << "_" << setw(2) << timeinfo->tm_mday;
result << "_" << setw(2) << timeinfo->tm_hour;
result << "_" << setw(2) << timeinfo->tm_min;
result << "_" << setw(2) << timeinfo->tm_sec;
return result.str();
}
c获取当前时间
最新推荐文章于 2024-07-07 12:33:03 发布