現在日時取得
// 現在日時取得
struct timeb raw_time;
ftime(&raw_time);
struct tm tm_loc;
localtime_r(&raw_time.time, &tm_loc);
char timestamp[25] = {0};
std::snprintf(timestamp, 25, "%4d/%02d/%02d %02d:%02d:%02d.%03d",
tm_loc.tm_year + 1900, tm_loc.tm_mon + 1, tm_loc.tm_mday, tm_loc.tm_hour, tm_loc.tm_min, tm_loc.tm_sec, raw_time.millitm);
printf("%s",timestamp);
网友评论