#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);
}
ubuntu C++ 获取当前系统时间
最新推荐文章于 2025-09-21 23:46:08 发布
本文介绍了一个C++函数,用于获取并格式化当前的系统时间,返回一个包含年月日及小时分钟秒的时间字符串。
1582

被折叠的 条评论
为什么被折叠?



