$now_time = time(); //当前时间
$for_time = mktime(0,0,0,2,24,2010);//设置一个日期
$n_time = $now_time-$for_time;
if( $n_time > 2592000 )
{
$echo = round($n_time/2592000).'月前';
}
elseif( $n_time > 6048000 )
{
$echo = round($n_time/604800).'周前';
}
elseif( $n_time > 86400 )
{
$echo = round($n_time/86400).'天前';
}
elseif( $n_time > 3600 )
{
$echo = round($n_time/3600).'小时前';
}
elseif( $n_time > 60 )
{
$echo = round($n_time/60).'分钟前';
}
else
{
$echo = $n_time.'秒前';
}
echo $echo;