public function getTimeDiff(DateTime $releaseDate)
    {
        $now = new DateTime();

        /** @var DateInterval $diff */
        $diff = $now->diff($releaseDate);

        if ($diff->days > 7) {
            return '';
        }

        if ($diff->days == 7) {
            return 'a week ago';
        }

        if ($diff->days >= 1) {
            return sprintf('%d day(s) ago', $diff->days);
        }

        if ($diff->h >= 1) {
            return sprintf('%d hour(s) ago', $diff->h);
        }

        if ($diff->i >= 1) {
            return sprintf('%d minute(s) ago', $diff->i);
        }

        return 'just now';
    }
public function getTimeDiff(DateTime $releaseDate)
    {
        $now = new DateTime();

        /** @var DateInterval $diff */
        $diff = $now->diff($releaseDate);

        if ($diff->days > 7) {
            return '';
        }

        if ($diff->days == 7) {
            return 'a week ago';
        }

        if ($diff->days >= 1) {
            return sprintf('%d day(s) ago', $diff->days);
        }

        if ($diff->h >= 1) {
            return sprintf('%d hour(s) ago', $diff->h);
        }

        if ($diff->i >= 1) {
            return sprintf('%d minute(s) ago', $diff->i);
        }

        return 'just now';
    }
public function getTimeDiff ( DateTime $ releaseDate ) { $ now = new DateTime ( ) ; /** @var DateInterval $diff */ $ diff = $ now -> diff ( $ releaseDate ) ; if ( $ diff -> days > 7 ) { return '' ; } if ( $ diff -> days == 7 ) { return 'a week ago' ; } if ( $ diff -> days >= 1 ) { return sprintf ( '%d day(s) ago' , $ diff -> days ) ; } if ( $ diff -> h >= 1 ) { return sprintf ( '%d hour(s) ago' , $ diff -> h ) ; } if ( $ diff -> i >= 1 ) { return sprintf ( '%d minute(s) ago' , $ diff -> i ) ; } return 'just now' ; }
Given a Date, calculate friendly how much time has passed

@param DateTime $releaseDate
@return string
Given a Date calculate friendly how much time has passed