Yii:TimeAgo

// Сколько прошло времени от настоящего момента public static function TimeAgo($time = null) { $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $periods_plural = array("seconds", "minutes", "hours", "days", "weeks", "months", "years", "decades"); $lengths = array("60","60","24","7","4.35","12","10"); $difference = time() - strtotime($time); for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) $difference /= $lengths[$j]; return Yii::t('server', "{n} $periods[$j] ago|{n} $periods_plural[$j] ago", round($difference)); }