获取当前时间字符串
std::string GetFormatTime()
{
time_t currentTime;
time(¤tTime);
tm* t_tm = localtime(¤tTime);
char formatTime[64] = {0};
snprintf(formatTime, 64, "%04d-%02d-%02d %02d:%02d:%02d",
t_tm->tm_year + 1900,
t_tm->tm_mon + 1,
t_tm->tm_mday,
t_tm->tm_hour,
t_tm->tm_min,
t_tm->tm_sec);
return std::string(formatTime);
}
获取系统当前时间所需要的包
#include <time.h>
time_t currentTime;
time(¤tTime);