undressbonifacio Posted May 28, 2010 Share Posted May 28, 2010 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 More sharing options...
Mchl Posted May 28, 2010 Share Posted May 28, 2010 SELECT *, TIME(SUM(timediff(idleend, idlestart))) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' GROUP BY agentid ORDER BY agentname Link to comment https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/#findComment-1064871 Share on other sites More sharing options...
undressbonifacio Posted May 31, 2010 Author Share Posted May 31, 2010 how come the 131.000000 become 00:01:31? it must be 00:02:11.. Link to comment https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/#findComment-1065603 Share on other sites More sharing options...
Mchl Posted May 31, 2010 Share Posted May 31, 2010 Nope. It's MySQL's time format. YYYYMMDDHHMMSS.mmmmmmm SELECT TIME(SUM(timediff(NOW(), NOW() - INTERVAL 130 SECOND))),SUM(timediff(NOW(), NOW() - INTERVAL 130 SECOND)) Link to comment https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/#findComment-1065618 Share on other sites More sharing options...
undressbonifacio Posted June 2, 2010 Author Share Posted June 2, 2010 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 https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/#findComment-1066793 Share on other sites More sharing options...
Mchl Posted June 2, 2010 Share Posted June 2, 2010 Green button at the bottom on the left (above quick reply) Link to comment https://forums.phpfreaks.com/topic/203229-how-to-get-total-hourminutesecond/#findComment-1066824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.