To achieve what you want, you can simply do
$target = strtotime("Feb 7 2013 2:15 AM");
$now = time();
$diff = $now - $target;
$days = floor(($diff)/24/60/60);
$hours = floor(fmod($diff, 24*60*60)/60/60);
$minutes = floor(fmod(fmod($diff, 24*60*60),60*60)/60);
echo $days . " days " . $hours . " hours " . $minutes . " minutes"; // e.g. "2 days 14 hours 54 minutes"
A more versatile solution
function timeago($timestamp) {
// Predefine variables
$timeago = '';
$past = FALSE;
$future = FALSE;
$prefixAgo = NULL;
$prefixFromNow = NULL;
$suffixAgo = "ago";
$suffixFromNow = "from now";
$wordSeperator = " ";
// Current time
$current = time();
// Seconds ago
$seconds = abs($current - $timestamp);
// Determine whether the time is in the future or the past
if ($current >= $timestamp) {
$past = TRUE;
} else {
$future = TRUE;
}
// Calculate time ago in different formats
$minutes = $seconds / 60;
$hours = $minutes / 60;
$days = $hours / 24;
$months = $days / 30;
$years = $days / 365;
// Format time ago according to calculated time
if ($seconds < 45) { $timeago = "less than a minute"; }
else if ($seconds < 90) { $timeago = "about a minute"; }
else if ($minutes < 45) { $timeago = round($minutes) . " minutes"; }
else if ($minutes < 90) { $timeago = "about an hour"; }
else if ($hours < 24) { $timeago = "about " . round($hours) . " hours"; }
else if ($hours < 42) { $timeago = "a day"; }
else if ($days < 30) { $timeago = round($days) . " days"; }
else if ($days < 45) { $timeago = "about a month"; }
else if ($days < 365) { $timeago = round($months) . " months"; }
else if ($years < 1.5) { $timeago = "about a year"; }
else { $timeago = round($years) . " years"; }
// Append prefix and suffix
if (!empty($prefixAgo)) { $prefixAgo = $prefixAgo . $wordSeperator; }
if (!empty($suffixAgo)) { $suffixAgo = $wordSeperator . $suffixAgo; }
if (!empty($prefixFromNow)) { $prefixFromNow = $prefixFromNow . $wordSeperator; }
if (!empty($suffixFromNow)) { $suffixFromNow = $wordSeperator . $suffixFromNow; }
if ($past) { $timeago = $prefixAgo . $timeago . $suffixAgo; }
if ($future) { $timeago = $prefixFromNow . $timeago . $suffixFromNow; }
// Return results
if (!empty($timeago)) {
return $timeago;
} else {
return NULL;
}
}