I use mktime
to create a unix timestamp from my current local time:
#include <time.h>
int _tmain(int argc, _TCHAR* argv[])
{
struct tm info;
// 16.05.2014
info.tm_mday = 16;
info.tm_mon = 5;
info.tm_year = 114; // Years since 1900
// 08:00:00 Uhr
info.tm_hour = 8;
info.tm_min = 0;
info.tm_sec = 0;
// Convert to Unix timestamp
info.tm_isdst = -1;
time_t timestamp = mktime(&info);
printf("Timestamp: %i", timestamp);
}
This gives me:
1402898400
When converting this back to a human readable time (via some website) this translates to:
16.06.2014 08:00:00
As you can see this is one month off from what I expected (put in May (5), got out June (6)). Why?