function format_date($time){
$t=time()-$time;
$f=array(
'31536000'=>'년',
'2592000'=>'개월',
'604800'=>'주',
'86400'=>'일',
'3600'=>'시간',
'60'=>'분',
'1'=>'초'
);
foreach ($f as $k=>$v) {
if (0 !=$c=floor($t/(int)$k)) {
return $c.$v.'전';
}
}
}