time2Units.php 'year', '个月'='month', '周'='week', '天'='day', '小时'='hour', '分钟'='minute', '秒'='second' ); foreach ( $unitArr as $cn = $u ){ if ( $$u 0 ){ $elapse = $$u . $cn; break; } } return $elapse;}$past = strtotime("201
'year', '个月'=>'month', '周'=>'week', '天'=>'day', '小时'=>'hour', '分钟'=>'minute', '秒'=>'second' ); foreach ( $unitArr as $cn => $u ){ if ( $$u > 0 ){ $elapse = $$u . $cn; break; } } return $elapse; } $past = strtotime("2017-01-12 21:49:00"); // Some timestamp in the past $now = time(); // Current timestamp $diff = $now - $past; echo '发表于' . time2Units($diff) . '前'; ?>