[英]Getting difference in time_t
I compute a start time like so ... 我这样计算开始时间...
time_t test = (int)difftime(time(0), gStatStartTime);
struct tm tempinfo;
localtime_s(&tempinfo, &test);
char buffer2[80];
strftime(buffer2, 80, "[%H:%M:%S]", &tempinfo);
time(&gStatStartTime);
When I compute a "stop" time for a 1-second run, however, my program prints [19:00:01]
. 但是,当我计算出运行1秒钟的“停止”时间时,程序将输出
[19:00:01]
。 The seconds value is correct, but the 19 hours is terribly wrong. 秒值是正确的,但19小时完全错误。 What could be the problem?
可能是什么问题呢?
使用gmtime_s()
代替localtime_s()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.