Display “time ago” instead of datetime in PHP Codeigniter
问题 I would like to display a time format like twitter and FB (Posted 3 hours ago, Posted 2 minutes ago and so on...) I've tried this piece of code without success : function format_interval($timestamp, $granularity = 2) { $units = array('1 year|@count years' => 31536000, '1 week|@count weeks' => 604800, '1 day|@count days' => 86400, '1 hour|@count hours' => 3600, '1 min|@count min' => 60, '1 sec|@count sec' => 1); $output = ''; foreach ($units as $key => $value) { $key = explode('|', $key); if (