You need
#include <time.h>
in your file to fix an incomplete type error.
Edit: given the day, month, year to find the time in seconds from January 1, 1970 to midnight on that day:
struct tm mytm = { 0 }; time_t result; mytm.tm_year = year - 1900; mytm.tm_mon = month - 1; mytm.tm_mday = day; result = mktime(&mytm); if (result == (time_t) -1) { } else { printf("%lld\n", (long long) result); }
Note that in ISO C, mktime() returns an integer value of type time_t that represents the time in the struct tm * argument, but the value of such an integral value is not necessarily βseconds since January 1, 1970.β This should not be in seconds. POSIX commits that time() , mktime() , etc., return seconds from January 1, 1970, so you should be fine. I mention above for completeness.
source share