public static function ago($dateTime, $full = false)
    {
        $dateTime = self::timestampToDate($dateTime);
        $now = new \DateTime();
        $ago = new \DateTime($dateTime);
        $diff = $now->diff($ago);

        $diff->w = floor($diff->d / 7);
        $diff->d -= $diff->w * 7;

        $string = [
            'y' => ':year',
            'm' => ':month',
            'w' => ':week',
            'd' => ':day',
            'h' => ':hour',
            'i' => ':minute',
            's' => ':second',
        ];
        foreach ($string as $k => &$v) {
            if ($diff->$k) {
                $v = $diff->$k.' '.$v.($diff->$k > 1 ? 's' : '');
            } else {
                unset($string[$k]);
            }
        }

        if (!$full) {
            $string = array_slice($string, 0, 1);
        }

        return $string ? implode(', ', $string).' ' : ':just';
    }
public static function ago($dateTime, $full = false)
    {
        $dateTime = self::timestampToDate($dateTime);
        $now = new \DateTime();
        $ago = new \DateTime($dateTime);
        $diff = $now->diff($ago);

        $diff->w = floor($diff->d / 7);
        $diff->d -= $diff->w * 7;

        $string = [
            'y' => ':year',
            'm' => ':month',
            'w' => ':week',
            'd' => ':day',
            'h' => ':hour',
            'i' => ':minute',
            's' => ':second',
        ];
        foreach ($string as $k => &$v) {
            if ($diff->$k) {
                $v = $diff->$k.' '.$v.($diff->$k > 1 ? 's' : '');
            } else {
                unset($string[$k]);
            }
        }

        if (!$full) {
            $string = array_slice($string, 0, 1);
        }

        return $string ? implode(', ', $string).' ' : ':just';
    }
public static function ago ( $ dateTime , $ full = false ) { $ dateTime = self :: timestampToDate ( $ dateTime ) ; $ now = new \ DateTime ( ) ; $ ago = new \ DateTime ( $ dateTime ) ; $ diff = $ now -> diff ( $ ago ) ; $ diff -> w = floor ( $ diff -> d / 7 ) ; $ diff -> d -= $ diff -> w * 7 ; $ string = [ 'y' => ':year' , 'm' => ':month' , 'w' => ':week' , 'd' => ':day' , 'h' => ':hour' , 'i' => ':minute' , 's' => ':second' , ] ; foreach ( $ string as $ k => & $ v ) { if ( $ diff -> $ k ) { $ v = $ diff -> $ k . ' ' . $ v . ( $ diff -> $ k > 1 ? 's' : '' ) ; } else { unset ( $ string [ $ k ] ) ; } } if ( ! $ full ) { $ string = array_slice ( $ string , 0 , 1 ) ; } return $ string ? implode ( ', ' , $ string ) . ' ' : ':just' ; }
Converts the timestamp in to ago form.

@param int|string $time Datetime, Timestamp or English textual datetime (http://php.net/manual/en/function.strtotime.php)

@author https://github.com/peter279k (https://github.com/zestframework/Zest_Framework/pull/206).

@since 3.0.0

@return mixed
Converts the timestamp in to ago form .