So I am using function to get the time from time with an offset of 555550 which should give a value of 10:19:09. But when I use gmtime and asctime I get a value of 10 seconds instead of 9 seconds, and I don’t understand why I am one second off. Could anyone please explain this?
Here is the code I am testing:
#include <stdio.h>
#include <time.h>
int main (void)
{
time_t now = 555550;
printf ("The time is %s", asctime (localtime (&now)));
printf ("UTC time is %s", asctime (gmtime (&now)));
return 0;
}
your calculation is wrong: see http://www.epochconverter.com/. 10 seconds is correct. How would a number divisible by 10 end up as 9 when modded by 60?