public static function timeSince($time)
{
$unix_timestamp = is_string($time) ? strtotime($time) : $time;
$seconds = time() - $unix_timestamp;
$minutes = $hours = $days = $weeks = $months = $years = 0;
if ($seconds == 0) {
$seconds = 1;
}
if ($seconds > 60) {
$minutes = $seconds / 60;
} else {
return self::timeSince_read($seconds, 'second');
}
if ($minutes >= 60) {
$hours = $minutes / 60;
} else {
return self::timeSince_read($minutes, 'minute');
}
if ($hours >= 24) {
$days = $hours / 24;
} else {
return self::timeSince_read($hours, 'hour');
}
if ($days >= 7) {
$weeks = $days / 7;
} else {
return self::timeSince_read($days, 'day');
}
if ($weeks >= 4) {
$months = $weeks / 4;
} else {
return self::timeSince_read($weeks, 'week');
}
if ($months >= 12) {
$years = $months / 12;
return self::timeSince_read($years, 'year');
} else {
return self::timeSince_read($months, 'month');
}
}