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

現在日時取得

// 現在日時取得
  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);
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。