ubuntu C++ 获取当前系统时间

#include 
#include 

std::string getCurrentTimeStr(){
  time_t t = time(NULL);
  char ch[64] = {0};
  char result[100] = {0};
  strftime(ch, sizeof(ch) - 1, "%Y%m%d--%H%M%S", localtime(&t));
  sprintf(result, "%s", ch);
  return std::string(result);
}

你可能感兴趣的:(小功能)