/**
* 用户得到与现在时间的间隔
* @param type $timestamp
* @return type
*/
function ago( $timestamp ) {
$difference = time() - strtotime($timestamp);
$difference = abs( $difference );
$periods = array("秒", "分钟", "小时", "天", "星期", "月", "年", "十年");
$lengths = array("60","60","24","7","4.35","12","10");
for( $j = 0; $difference >= $lenghts[$j]; $j++ ) {
$difference = $difference / $lengths[$j];
}
$difference = floor($difference);
$text = "$difference $periods[$j]前";
return $text;
}