简体   繁体   中英

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] . The seconds value is correct, but the 19 hours is terribly wrong. What could be the problem?

使用gmtime_s()代替localtime_s()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM