C++在windows下,给出了日期,比如(2011-09-13 17:22:00),如何计算UNIX时间戳?

2024-12-26 21:48:05
推荐回答(1个)
回答1:

#include

using namespace std;

unsigned int GetTick(int iY,int iM,int iD,int iH,int iMin,int iS)
{
struct tm stm;
memset(&stm,0,sizeof(stm));
stm.tm_year=iY-1900;
stm.tm_mon=iM-1;
stm.tm_mday=iD;
stm.tm_hour=iH;
stm.tm_min=iMin;
stm.tm_sec=iS;
return (unsigned int)mktime(&stm);
}

int main()
{
cout< system("pause");
return 0;
}