
How to write a code to get review date on Single Employer Page
Question:
I'll replace the "By: Mr. A" by the review date. For example, if Mr. A reviewed 5 min ago, it will display "5 min ago", or if Mr. A reviewed 2 days ago, it will display "2 days ago"
Answer:
add new function code to line 164
function elapsedTime($time_since) {
$time = time() - $time_since;
$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':'');
}
}
add new code to line 200
echo elapsedTime($item_review->time) .' ago';
I hope it help you