我想获得UTC或GMT相对于MFC当前系统时间的时间。我尝试过使用CTime的GetGmtTm(),如下所示
struct tm* osTime=NULL;
tm t1 = *(currenttime.GetGmtTm( osTime ));
CTime currentUTCTime(1900+t1.tm_year, t1.tm_mon+1, t1.tm_mday, t1.tm_hour, t1.tm_min, t1.tm_sec, t1.tm_isdst);
CTimeSpan ts = currentUTCTime - oldtime; //oldtime points to Unix Epoch 1/1/1970 00:00:00
unsigned long time = ts.GetTotalSeconds( );//to get the Unix time但它并没有像预期的那样正常工作。对于像阿斯塔纳(GMT+6.00)这样的一些时区,达卡获得的是协调世界时的时差12小时。
有人能帮我找到解决方案吗?
提前感谢您:)
发布于 2011-03-09 21:33:01
CTime::GetTime()返回unixtime -它总是以从纪元开始的秒数来表示(定义为UTC/GMT时间)。
https://stackoverflow.com/questions/5246481
复制相似问题