/ Published in: PHP
Accepts a UNIX timestamp, like the result of time(), and formats it into "# (days/months/etc) ago"
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function ago($time) { $difference = $now - $time; $tense = "ago"; $difference /= $lengths[$j]; } if($difference != 1) { $periods[$j].= "s"; } return "$difference $periods[$j] 'ago' "; }
URL: http://css-tricks.com/snippets/php/time-ago-function/