try this. I tested it and it worked perfectly 🙂
<?
function timeDiff($timestamp,$detailed=false,$n = 0){
$now = time();
#If the difference is positive "ago" - negative "away"
($timestamp >= $now) ? $action = 'away' : $action = 'ago';
$diff = ($action == 'away' ? $timestamp - $now : $now - $timestamp);
# Set the periods of time
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
# Go from decades backwards to seconds
$i = sizeof($lengths) - 1; # Size of the lengths / periods in case you change them
$time = ""; # The string we will hold our times in
while($i >= $n) {
if($diff > $lengths[$i-1]) { # if the difference is greater than the length we are checking... continue
$val = floor($diff / $lengths[$i-1]); # 65 / 60 = 1. That means one minute. 130 / 60 = 2. Two minutes.. etc
$time .= $val ." ". $periods[$i-1].($val > 1 ? 's ' : ' '); # The value, then the name associated, then add 's' if plural
$diff -= ($val * $lengths[$i-1]); # subtract the values we just used from the overall diff so we can find the rest of the information
if(!$detailed) { $i = 0; } # if detailed is turn off (default) only show the first set found, else show all information
}
$i--;
}
# Basic error checking.
if($time == "") {
return "Error-- Unable to calculate time.";
} else {
return $time.$action;
}
}
$yourdate = "2007-08-02 12:25:58";
$sets = explode(" ", $yourdate);
$date_array = explode("-", $sets[0]);
$updated_date = $date_array[1]."/".$date_array[2]."/".$date_array[0]." ".$sets[1];
$yourtimestamp = strtotime($updated_date);
echo timeDiff($yourtimestamp,1,1);
?>