‘year’, ‘个月’=>’month’, ‘周’=>’week’, ‘天’=>’day’,
‘小时’=>’hour’, ‘分钟’=>’minute’, ‘秒’=>’second’
);
foreach ( $unitArr as $cn => $u )
{
if ( $$u > 0 )
{
$elapse = $$u . $cn;
break;
}
}
return $elapse;
}
$past = 2052345678; // Some timestamp in the past
$now = time(); // Current timestamp
$diff = $now – $past;
echo ‘发表于’ . time2Units($diff) . ‘前’;
?>
哈哈哈哈哈哈哈哈哈哈