time difference
-
How to get time difference in seconds. CTime t1; t1.GetCurrentTime(); after some time say after 3 seconds CTime t2; t2.GetCurrentTime(); Now I want difference between t2 and t1 in seconds that is 3 seconds; Marcoslav
Instead of all the above use
DWORD dwStartTime = GetTickCount(); //Some Code DWORD dwStopTime = GetTickCount(); Now the Difference ( dwStopTime - dwStartTime )
gives u the required difference in Seconds Appu.. "If you judge people, you have no time to love them." -
Instead of all the above use
DWORD dwStartTime = GetTickCount(); //Some Code DWORD dwStopTime = GetTickCount(); Now the Difference ( dwStopTime - dwStartTime )
gives u the required difference in Seconds Appu.. "If you judge people, you have no time to love them." -
How to get time difference in seconds. CTime t1; t1.GetCurrentTime(); after some time say after 3 seconds CTime t2; t2.GetCurrentTime(); Now I want difference between t2 and t1 in seconds that is 3 seconds; Marcoslav
In MFC, use subtract operator and
CTimeSpan
class:CTime time1 = CTime::GetCurrentTime(); ::Sleep(3000); CTime time2 = CTime::GetCurrentTime(); CTimeSpan diff = time2 - time1; LONG seconds = diff.GetTotalSeconds();
Note the usage of
CTime::GetCurrentTime
static function. -
NiceNaiduNow the Difference ( dwStopTime - dwStartTime ) gives u the required difference in Seconds
I think this will return the difference in milli seconds.. nave
Yes .u r right. U will get the time difference in milli seconds. Divide the difference with 1000 to get Seconds. Thanks for the correction Naveen. Appu.. "If you judge people, you have no time to love them."
-
How to get time difference in seconds. CTime t1; t1.GetCurrentTime(); after some time say after 3 seconds CTime t2; t2.GetCurrentTime(); Now I want difference between t2 and t1 in seconds that is 3 seconds; Marcoslav
marcoslav wrote:
t1.GetCurrentTime();
Wrong. Use this instead:
t1 = CTime::GetCurrentTime();
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb