我不知道为什么,但返回2小时前所有以下日期以下/时间PHP前段时间函数返回4小时所有日期
function ago($timestamp){
$difference = floor((time() - strtotime($timestamp))/86400);
$periods = array("second", "minute", "hour", "day", "week", "month", "years", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
for($j = 0; $difference >= $lengths[$j]; $j++)
$difference /= $lengths[$j];
$difference = round($difference);
if($difference != 1)
$periods[$j].= "s";
$text = "$difference $periods[$j] ago";
return $text;
}
我送的日期是
"replydate": "29/07/2012CDT04:54:27",
"replydate": "29/07/2012CDT00:20:10",
我认为你重写了循环内部的差异。 – 2012-07-29 10:17:19
你是什么意思? – RussellHarrower 2012-07-29 10:20:34