In a simple test getting the elapsed time in seconds since de Unix Epoch (01/01/1970 00:00:00 UTC) to 22 of February of 2019, it has returned a huge number of 18446744072104596016
Why not just 1550793600 seconds?
Isn't the time_t
value portable?
The tm struct
printed out in gdb console had the following values just before calling mktime()
:
(gdb) p ltm
$4 = {tm_sec = 0, tm_min = 0, tm_hour = 0, tm_mday = 22, tm_mon = 1, tm_year = 19, tm_wday = 0, tm_yday = 0, tm_isdst = 0}
time_t
value?mktime()
returning such a huge value.tm_year = 19
that's year 1919, it's returning a big negative number.18446744072104596016
if a 64-bittime_t
is viewed as an unsigned value.