difftime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patrickv
    New Member
    • Mar 2008
    • 1

    difftime

    Hello All,
    I have a problem with difftime.
    I have 2 strings containing a time. I must calculate the difference of this 2 strings into seconds.
    This is my code:

    double Seconds;
    double Timeout;
    unsigned char firsttime[8];
    unsigned char secondtime[8];
    char *timestr;
    time_t first;
    time_t second;

    // check time out of 300 seconds between datwsh and WsDate
    timestr= pTrxIn->DatWsh; //string with date time
    memcpy(firsttim e,timestr+8,8); //timestring

    timestr= pTrxIn->WsDate; //string with datetime
    memcpy(secondti me,timestr+8,8) ; //timestring

    first = (time_t)atol(fi rsttime);
    second = (time_t)atol(se condtime);

    Seconds = (difftime(secon d,first));
    Timeout = atof(pTrxIn->TimeOut); //string containing "300"
    if (Seconds > Timeout)
    {
    return "timeout reached";
    }

    return 0;

    He gives me the time in 100? Not in 60?
    I do somthing wrong, but what?
    Regards,
    Patrick
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    difftime returns the difference in total number of seconds.
    If you want to display it in minutes and seconds you want to convert it manually

    Raghuram

    Comment

    Working...