<?php
function format_date( $time )
{
$time_difference = time() -$time + 32400;
if( $time_difference < 1 ) { return '방금 전'; }
$condition = array( 12 * 30 * 24 * 60 * 60 => '년',
30 * 24 * 60 * 60 => '달',
24 * 60 * 60 => '일',
60 * 60 => '시간',
60 => '분',
1 => '초'
);
foreach( $condition as $secs => $str )
{
$d = $time_difference / $secs;
if( $d >= 1 )
{
$t = round( $d );
return $t . '' . $str . ( $t > 1 ? '' : '' ) . '전';
}
}
}
echo format_date(get_comment_time('U'));