src/Plugin.php
protected function ago($time)
    {
        $time = time() - $time;

        if ($time < 60) {
            return 'a moment ago';
        }

        $secs = array(
            'year'   => 365.25 * 24 * 60 * 60,
            'month'  => 30 * 24 * 60 * 60,
            'week'   => 7 * 24 * 60 * 60,
            'day'    => 24 * 60 * 60,
            'hour'   => 60 * 60,
            'minute' => 60,
        );

        foreach ($secs as $str => $s) {
            $d = $time / $s;

            if ($d >= 1) {
                $r = round($d);
                return sprintf('%d %s%s ago', $r, $str, ($r > 1) ? 's' : '');
            }
        }
    }
protected function ago($time)
    {
        $time = time() - $time;

        if ($time < 60) {
            return 'a moment ago';
        }

        $secs = array(
            'year'   => 365.25 * 24 * 60 * 60,
            'month'  => 30 * 24 * 60 * 60,
            'week'   => 7 * 24 * 60 * 60,
            'day'    => 24 * 60 * 60,
            'hour'   => 60 * 60,
            'minute' => 60,
        );

        foreach ($secs as $str => $s) {
            $d = $time / $s;

            if ($d >= 1) {
                $r = round($d);
                return sprintf('%d %s%s ago', $r, $str, ($r > 1) ? 's' : '');
            }
        }
    }
protected function ago ( $ time ) { $ time = time ( ) - $ time ; if ( $ time < 60 ) { return 'a moment ago' ; } $ secs = array ( 'year' => 365.25 * 24 * 60 * 60 , 'month' => 30 * 24 * 60 * 60 , 'week' => 7 * 24 * 60 * 60 , 'day' => 24 * 60 * 60 , 'hour' => 60 * 60 , 'minute' => 60 , ) ; foreach ( $ secs as $ str => $ s ) { $ d = $ time / $ s ; if ( $ d >= 1 ) { $ r = round ( $ d ) ; return sprintf ( '%d %s%s ago' , $ r , $ str , ( $ r > 1 ) ? 's' : '' ) ; } } }
Returns a crude time ago string.

@param int $time Origin timestamp

@return string
Returns a crude time ago string .