我不知道爲什麼,但返回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