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

#include <stdio.h>
#include <time.h>

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);
}
发布了50 篇原创文章 · 获赞 31 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/random_repick/article/details/102668761
今日推荐