获取时间|求加团
2026-07-03 18:09:21
发布于:浙江
#include <iostream>
#include <chrono>
#include <iomanip>
#include <sstream>
stdstring getCurrentTime() {
// 获取当前时间点
auto now = stdchronosystem_clocknow();
// 转换为time_t类型
auto now_c = stdchronosystem_clockto_time_t(now);
// 使用localtime获取本地时间
stdtm* now_tm = std::localtime(&now_c);
// 使用stringstream将时间转换为字符串
std::stringstream ss;
ss << std::put_time(now_tm, "%Y-%m-%d %H:%M:%S");
return ss.str();
}
int main() {
stdstring timeStr = getCurrentTime();
stdcout << "Current time is: " << timeStr << std::endl;
return 0;
}
记得关注哦
加团链接:https://www.acgo.cn/application/2071131662524678144
这里空空如也





















有帮助,赞一个