0
我只是需要一個提示功能,顯示以前的格式的時間。 在我的數據庫中,我有時間作爲時間戳記。有來自用戶的評論作爲時間戳。這個日期需要及時轉換。我有一個功能,但不能爲每個評論召回。它只有1次發表1條評論。有人可以幫忙嗎?php時間前功能
這是我的功能
function humanTiming($time)
{
$time = time() - $time; // to get the time since that moment
$time = ($time<1)? 1 : $time;
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time/$unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}
你轉換時間戳劃時代它傳遞給'humanTiming前()' –
不,我不@DanielSmith –
是你的權利@GautamKrishnaR但功能不能重新聲明2個註釋例如。 –