/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function relativeTime($time = false, $limit = 86400, $format = 'g:i A M jS') { $relative = ''; if ($time === $now) $relative = 'now'; elseif ($time > $now) $relative = 'in the future'; else { $diff = $now - $time; elseif ($diff < 60) { $relative = 'less than one minute ago'; $relative = $minutes.' minute'.(((int)$minutes === 1) ? '' : 's').' ago'; } else { $relative = 'about '.$hours.' hour'.(((int)$hours === 1) ? '' : 's').' ago'; } } return $relative; }