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
https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.