[Solved] Date Function, Help
Posted: Sat Apr 30, 2005 7:35 pm
I made a small function to display the difference between two dates.
The seconds and minutes work, but the hours dont. I am getting 17hours when it should be about 1.3hours. Whats going wrong?
Code: Select all
<?php
function displaytime($postedtime, $time){
$diff = $time-$postedtime;
if($diff < 60){
return date("s", $diff) . " seconds ago";
}elseif($diff >= 60 && $diff < 3600){
return date("i", $diff) . " minutes ago";
}elseif($diff >= 3600 && $diff < 86400){
return date("H", $diff) . " hours ago";
}elseif($diff >= 86400){
return date("d", $diff) . " days ago";
}else{
return "Older Than 1 Month";
}
}
?>