Two time comparison

Source: Internet
Author: User
#include <time.h>
#include <Windows.h>
#include <iostream>
using namespace Std;
Float difftime (unsigned ty1, unsigned th1, unsigned ty2, unsigned th2)


{


struct TM TM1, TM2;


time_t tt1, TT2;


float DT;






Tm1.tm_year = ty1/10000-1900; Get the year 2008


Tm1.tm_mon = (ty1% 10000)/100; Get the Month 09


Tm1.tm_mday = (ty1% 10000)% 100; Get the day 11


Tm1.tm_hour = th1/10000; Get when 11


Tm1.tm_min = (th1% 10000)/100; Get the score 12


tm1.tm_sec = (th1% 10000)% 100; Get seconds 03






Tm2.tm_year = ty2/10000-1900; Get the year 2008


Tm2.tm_mon = (ty2% 10000)/100; Get the Month 09


Tm2.tm_mday = (ty2% 10000)% 100; Get the day 13


Tm2.tm_hour = th2/10000; Get when 11


Tm2.tm_min = (Th2% 10000)/100; Get the score 12


tm2.tm_sec = (th2% 10000)% 100; Get seconds 01






TT1 = Mktime (&AMP;TM1);


TT2 = Mktime (&AMP;TM2);


DT = (float) (Difftime (TT2, TT1)); Get the difference in minutes/60


return DT;


}


int main (void)
{


/* Function Description: Difftime.


Input: Ty1 20080911 in the previous time


Th1 111203 seconds before a moment


Ty2 20080913 in the first moment of the month


Th2 111201 seconds before a moment


Output: Number of minutes minutes interval


*/
cout << difftime (20080913, 111403, 20080913, 111301);


return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.