Reputation: 11
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;
}
Upvotes: 0
Views: 159
Reputation: 11658
according to http://www.epochconverter.com/ the value of 555550 is Wed, 07 Jan 1970 10:19:10 GMT, so your assumption about 555550 to be 10:19:09 was wrong.
Upvotes: 1
Reputation: 14281
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?
Upvotes: 3