近来有不少人问这问题,所以写到这来,免得重复回答
#include <time.h>
#include <iostream>
using std::cout;
int main (int argc, char* argv[])
{
struct tm* when = (struct tm*) malloc (sizeof (tm);
when->tm_year = 105;//2005.07.21 22:35:23 year = cur year - 1900
when->tm_mon = 7;
when->tm_mday = 21;
when->tm_hour =21;
when->tm_min = 35;
when->tm_sec = 23;
t = mktime (when);
cout << t << endl;
return 0;
}