The following code prints the difference in hours and minutes between 2 Unix timestamps. Modify it to suit your purposes🙂
<?php
// timestamp from 6AM, March 2nd, 2002
$dbStamp = mktime(6, 0, 0, 3, 2, 2002);
//current timestamp
$currentStamp = mktime();
// calculate difference in hours
$hours = ($currentStamp - $dbStamp)/60/60;
// get the whole and decimal portions of the $hours float
$tmp = explode(".",$hours);
// substract the hours from the float, multiply by 60 to get the minutes, and round down to 0 decimals
$minutes = floor((($hours - $tmp[0]) * 60));
// print the time info
echo "Time Difference: $tmp[0] hours and $minutes minutes<br>\n";
?>
-geoff