I have the following code:
struct tm time; strptime("27052010", "%d%m%Y", &time); cout << "sec: " << time.tm_sec << "\n"; cout << "min: " << time.tm_min << "\n"; cout << "hour: " << time.tm_hour << "\n"; cout << "day: " << time.tm_mday << "\n"; cout << "month: " << (time.tm_mon + 1) << "\n"; cout << "year: " << time.tm_year << "\n"; time_t t = mktime(&time); cout << "sec: " << time.tm_sec << "\n"; cout << "min: " << time.tm_min << "\n"; cout << "hour: " << time.tm_hour << "\n"; cout << "day: " << time.tm_mday << "\n"; cout << "month: " << (time.tm_mon + 1) << "\n"; cout << "year: " << time.tm_year << "\n"; cout << "time: " << t << "\n";
Conclusion:
sec: 1474116832 min: 32767 hour: 4238231 day: 27 month: 5 year: 110 sec: 52 min: 0 hour: 6 day: 2 month: 9 year: 640 time: 18008625652 (Fri, 02 Sep 2540 04:00:52 GMT)
My question is: why does mktime() change the values ββof time and why the converted time_t does not match my input date. I expect the exit to be a date, expressed in seconds since 1970 (05/27/2010 = 1330905600).
Thanks in advance
aQuip source share