C 时间函数问题

Issue with c++ time function.

本文关键字:问题 函数 时间      更新时间:2023-10-16

因此,我正在使用功能以从555550的偏移中获得时间的时间,该值应给出10:19:09的值。但是,当我使用GMTime和Asctime时,我的价值为10秒而不是9秒,而我不明白为什么我会休息一秒钟。有人可以解释一下吗?

这是我正在测试的代码:

#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;
}

您的计算是错误的:请参阅http://www.epochconverter.com/。10秒是正确的。当通过60的修改时,一个数字如何最终为9?

根据http://www.epochconverter.com/555550的价值是星期三,1970年1月7日10:19:10格林尼治标准时间,因此您的假设约为10:19:09是错误的。