localtime_s时间转换为字符串


std::string getTime(void)

{
time_t now;
time(&now);


// 定义两个变量,存储转换结果
struct tm tmTmp;
char stTmp[TIME_MAX];


// 转换为tm结构
localtime_s(&tmTmp, &now);


// 转换为字符串并输出
asctime_s(stTmp, &tmTmp);
std::string a;
for (int i = 11; i < 19; i++)
{
a += stTmp[i];
}
return a;
}

猜你喜欢

转载自blog.csdn.net/z13724549107/article/details/80552031
今日推荐