c++ 时间格式化
作者:互联网
1.概要
c++ 时间格式化
2.代码
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
string getTime()
{
time_t timep;
time(&timep);
char tmp[64];
strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep));
return tmp;
}
int main()
{
string time = getTime();
cout << time << endl;
std::cout << "Hello World!\n";
}
3.运行
4.使用环境
vs2019
5.备注
标签:tmp,-%,格式化,getTime,timep,c++,时间,time,include 来源: https://blog.csdn.net/xie__jin__cheng/article/details/118519594