Thanks for replies.
They help.
I got the average function working.
I just don't understand why I need to subtract 5 from the hours?
<?
$lastvisit = strtotime('1970-01-01 20:00:00'); // The start date becomes a timestamp
$currentdate = strtotime('1970-01-01 10:00:00');
print " $lastvisit <br><br>";
print" $currentdate <br><br>";
//$difference = round(($currentdate + $lastvisit)/ 2);
//$difference = ($currentdate - $lastvisit);
//if ($currentdate > $lastvisit)
$difference =($currentdate + $lastvisit) /2;
// else
//$difference = ($lastvisit + $currentdate) /2;
$hours = floor($difference / 3600);
$remainder = $difference % 3600;
$minutes = floor($remainder / 60);
$remainder = $remainder % 60;
$seconds = $remainder;
$intmin = intval($minutes);
$inthour = intval($hours);
//floor($minutes);
//$hours = $difference % 3600;
//$minutes = $difference % 60;
//$seconds = $difference - ( intval($minutes) * 60 );
//$intmin = intval($minutes);
//$inthour = intval($hours);
if ($inthour == "1") { $hour = "hour"; } else { $hour = "hours"; }
if ($intmin == "1") { $minute = "minute"; } else { $minute = "minutes"; }
if ($seconds == "1") { $second = "second"; } else { $second = "seconds"; }
//if ($hours < 1) { $hours = 0; }
//if ($minutes < 1) { $minutes = 0; }
$hours = $hours- 5;
print ("Avg is : $hours, $minutes and $seconds ago.\n");
?>