C++系统时间

来源:互联网 发布:淘宝上的耐克是正品吗 编辑:程序博客网 时间:2024/06/06 20:18
 

 取系统时间

 

 

计算系统时间差得方法:

1,通过FILETIME结构体

 

2,通过tm结构体

 
tm ctBeg, ctEnd;DWORD dwTimeRet = 0;CTime currentTime,cTime;currentTime = CTime::GetCurrentTime();memset(&ctBeg, 0, sizeof(ctBeg));memset(&ctEnd, 0, sizeof(ctEnd));int xtem = interMap->second.cTime.tm_yday;ctBeg.tm_year = cTime.tm_year - 1900;ctBeg.tm_mon  = cTime.tm_mon;    // 到 [0, 11]ctBeg.tm_mday = cTime.tm_mday;ctBeg.tm_hour = cTime.tm_hour;ctBeg.tm_min  = cTime.tm_min;ctBeg.tm_sec  = cTime.tm_sec;ctBeg.tm_isdst = -1;ctEnd.tm_year = currentTime.GetYear() - 1900; ctEnd.tm_mon  = currentTime.GetMonth();    // 到 [0, 11]ctEnd.tm_mday = currentTime.GetDay();ctEnd.tm_hour = currentTime.GetHour();ctEnd.tm_min  = currentTime.GetMinute();ctEnd.tm_sec  = currentTime.GetSecond();ctEnd.tm_isdst = -1;time_t ctBeg_t = mktime(&ctBeg);time_t ctEnd_t = mktime(&ctEnd);dwTimeRet = ctEnd_t - ctBeg_t;

tm_isdst 的值表示:1表示有影响,启用夏令时;0表示没影响,-1表示不起作用
原创粉丝点击