locked
How to get time differences in metro app?

    Question

  • Hi,

    How to get two time differences in seconds or milli-seconds

    say >>

    02:10:15  and 02:10:25

    difference = 10 seconds

    Or

    in milli-seconds

    Monday, September 24, 2012 9:10 AM

Answers

  • Hi Sujith,

      You can use  GetTickCount64() API to get the time difference in milli-seconds.

    • Marked as answer by _Sujith Monday, September 24, 2012 9:55 AM
    Monday, September 24, 2012 9:45 AM
  • Hi Suresh,

    ur answer helped partially. Thanks

    • Marked as answer by _Sujith Thursday, October 04, 2012 4:32 AM
    Monday, September 24, 2012 9:55 AM

All replies

  • Hi Sujith,

      You can use  GetTickCount64() API to get the time difference in milli-seconds.

    • Marked as answer by _Sujith Monday, September 24, 2012 9:55 AM
    Monday, September 24, 2012 9:45 AM
  • Hi Suresh,

    ur answer helped partially. Thanks

    • Marked as answer by _Sujith Thursday, October 04, 2012 4:32 AM
    Monday, September 24, 2012 9:55 AM
  • Sujith,  you can use the following code snapped....

    unsigned long long GetCurrentTime() 
      {
            unsigned long long currentTime;
    	LARGE_INTEGER pCounter;
    	if( false == QueryPerformanceCounter(&pCounter) ) 
                   {
    	            currentTime = GetTickCount64();
    	       } 
             else {
    		LARGE_INTEGER pFreqency;
    		QueryPerformanceFrequency(&pFreqency);
    		currentTime = (pCounter.QuadPart * 1000)/ pFreqency.QuadPart;
    		}
      return currentTime;
      } 
    
    
    unsigned long long tt;
    
    tt = GetCurrentTime();
    /*
    * Do some
    * task
    */
    tt = GetCurrentTime() - tt;  
    

    Here tt is the time difference in milliseconds.

    Monday, September 24, 2012 4:07 PM
  • thanks Hossain
    Tuesday, September 25, 2012 4:14 AM
  • Hi   _Sujith,

    If you have got your answer please it "Marked As Answer" or vote as helpful so that others can understand and become benefited.


    Monday, October 01, 2012 3:30 PM