C++ 获取时间戳并转换时间
程序员文章站
2022-03-22 21:37:52
...
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
time_t curtime;
curtime = time(NULL);
cout<<curtime<<endl;
char temp[100];
curtime += 28800;
struct tm *timeSet = gmtime(&curtime);
strftime(temp,50, "%Y-%m-%d %H:%M:%S", timeSet);
cout << temp << endl;
return 0;
}