Anyways, this displays hours, minutes and seconds:
$query = mysql_query("SELECT SEC_TO_TIME(AVG(TIMESTAMPDIFF(SECOND, `firstcontactdate`,`dateadded`))) FROM leads WHERE userid = $userid AND firstcontactdate != '0000-00-00 00:00:00'");
$queryresult = mysql_fetch_array($query);
echo $queryresult[0];
It would be good if I could get it to display the actual text ‘hours’, ‘minutes’ and ‘seconds’ too, any suggestions? I’m not familiar with MYSQL, I’ve looked at the dev guides.
I’m really a massive noob when it comes to PHP and MYSQL, only played around it with in the last few weeks. May I ask how you think I should go about formatting it with application code? Currently I am having to work with:
‘Your average contact time is 30:39:32 (hours, minutes, seconds)’
The ($seconds!=1?'s':'') bit is kinda the same as if ($seconds != 1) { echo 's'; } else { echo ''; }. It’s known as the ternary operator ( :google: it )