#include <iostream>
#include <time.h>
using namespace std;
int main() {
time_t tt;
time( &tt );
tt = tt + 8*3600; // transform the time zone
tm* t= gmtime( &tt );
cout << tt << endl;
cout<< t->tm_year + 1900<<
t->tm_mon + 1<<
t->tm_mday<<
t->tm_hour<<
t->tm_min<<
t->tm_sec<<endl;
return 0;
}
`结果::
1566378427
2019821977
此方法为了 将Windows下的VS C++程序 迁移到Ubuntu上时,需要调整一部分原始代码!