Jump to content

how to get total hour:minute:second


undressbonifacio

Recommended Posts

hello everyone

 

im new here in your community...

 

may i ask how to convert this into hour:minute:second?

SELECT *, SUM(timediff(idleend, idlestart)) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' GROUP BY agentid ORDER BY agentname

 

the totalidle=131.000000

 

Link to comment
Share on other sites

hello Mchl, thank for your idea...

 

this is my version

function secToTime($s)
{
  if ($s > 0)
  {
    $mins = floor ($s / 60);
    $secs = $s % 60;

    $hrs = floor ($mins / 60);
    $mins = $mins - ($hrs*60);

    $hrs = sprintf("%02d",$hrs);
    $mins = sprintf("%02d",$mins);
    $secs = sprintf("%02d",$secs);
    return $hrs.':'.$mins.':'.$secs;
  }
}

 

after this query

$myquery = "SELECT *, SUM(timediff(idleend, idlestart)) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' AND idleend!='0000-00-00 00:00:00' GROUP BY agentid ORDER BY agentname";

echo secToTime($row['totalidle']);

 

it will return perfect...

 

thanks again dude..

 

BTW how to tag this as SOLVED?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.