converting  a timestamp of the format 2009-09-12 20:57:19 and turn it into something like 3 minutes ago with PHP.

Use example :

echo time_elapsed_string('2016-05-01 00:22:35');
echo time_elapsed_string
('@1367367755'); # timestamp input
echo time_elapsed_string
('2016-05-01 00:22:35', true);

Output :

4 months ago
4 months, 2 weeks, 3 days, 1 hour, 49 minutes, 15 seconds ago

Function :

function time_elapsed_string($datetime, $full = false) {
$now
= new DateTime;
$ago
= new DateTime($datetime);
$diff
= $now->diff($ago);

$diff
->w = floor($diff->d / 7);
$diff
->d -= $diff->w * 7;

$string
= array(
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v
= $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset
($string[$k]);
}
}

if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
the above php function will convert the timstamp into the "ago" format..
this function is working for me.. if you have any problem comment below...