美文网首页
C++ 获取现在时间 精确到毫秒

C++ 获取现在时间 精确到毫秒

作者: Vwwwwww | 来源:发表于2020-05-29 15:40 被阅读0次

現在日時取得

// 現在日時取得
  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);

相关文章

网友评论

      本文标题:C++ 获取现在时间 精确到毫秒

      本文链接:https://www.haomeiwen.com/subject/jazxzhtx.html