$time = time() - strtotime($created_at); // $created_at is a string of time i.e. Fri Mar 18 17:24:35 PDT 2011
$days = floor($time/24/60/60);
if ($days > 0) {
$days_out = "$days day";
$days_out .= $days > 1 ? 's' : '' .", ";
}
$hours = floor(($time % (24*60*60))/60/60);
$hours_out = "{$hours} hour";
$hours_out .= $hours > 1 ? 's' : '' . " ago";
echo "{$days_out}{$hours_out}";
Comments
Leave comment
Trackback