Simple PHP Time Ago Function

I tend to use Time Ago often in my Code Canyon scripts to show when a post, comment or other various action was completed.

This function calculates the time ago from the passed timestamp ($date).

/*
 * Function to convert a Timestamp to a Time Ago
 *
 * @param string $date    The Timestamp
 */
function timeago($date) {
    if (empty($date)) {
        return "No date provided";
    }
    $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
    $lengths = array("60","60","24","7","4.35","12","10");

    $now = time();
    $unix_date = strtotime($date);

    // check validity of date
    if (empty($unix_date)) {
        return "";
    }

    // is it future date or past date
    if ($now > $unix_date) {
        $difference = $now - $unix_date;
        $tense = "ago";
    } else {
        $difference = $unix_date - $now;
        $tense = "from now";
    }

    for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
        $difference /= $lengths[$j];
    }

    $difference = round($difference);

    if ($difference != 1) {
        $periods[$j].= "s";
    }

    return "$difference $periods[$j] {$tense}";
}

Basic Usage:

<?php echo timeago('2015-11-13 09:00:00'); ?>

Will return (at the time of posting): 24 minutes ago.