<?php
function convertime($ptime) {
$etime = time() - $ptime;
if ($etime < 60) {
return 'less than minute ag';
}
$a = array(
'year' => 12 * 30 * 24 * 60 * 60,
'month' => 30 * 24 * 60 * 60,
'day' => 24 * 60 * 60,
'hour' => 60 * 60,
'minute' => 60
);
$result = array();
foreach ($a as $period => $secs) {
$d = $etime / $secs;
if ($d >= 0) {
$result[$period] = floor($d);
$etime = $etime - ($secs * $result[$period]);
}
}
print_r($result);
}
$ctime = strtotime('2009-02-23 10:09:00'); //time from mysql
echo convertime($ctime);
?>