public static function lastUpdated($date, $withTime = true): string
    {
        $objDate = self::parse($date);
        $date = self::parse($objDate)->format('Y-m-d');
        $days = self::parse(Date('Y-m-d'))->diffInDays(self::parse($date));

        if ($days == 0) {
            $msg = 'today';
        } elseif ($days == 1) {
            $msg = 'yesterday';
        } elseif ($days > 1 && $days < 7) {
            $msg = $objDate->format('l');
        } elseif ($days >= 7 && $days < 32) {
            $msg = $days . ' days ago';
            $withTime = false;
        } elseif ($days >= 32 && $days < 365) {
            $months = self::parse(Date('Y-m-d'))->diffInMonths($objDate);
            $msg = $months . (($months > 1) ? ' months ' : ' month ') . 'ago';
            $withTime = false;
        } else {
            $years = self::parse(Date('Y-m-d'))->diffInYears($objDate);
            $msg = $years . (($years > 1) ? ' years ' : ' year ') . 'ago';
            $withTime = false;
        }

        return ($withTime) ? $msg . ' at ' . $objDate->format('g:ia') : $msg;
    }
public static function lastUpdated($date, $withTime = true): string
    {
        $objDate = self::parse($date);
        $date = self::parse($objDate)->format('Y-m-d');
        $days = self::parse(Date('Y-m-d'))->diffInDays(self::parse($date));

        if ($days == 0) {
            $msg = 'today';
        } elseif ($days == 1) {
            $msg = 'yesterday';
        } elseif ($days > 1 && $days < 7) {
            $msg = $objDate->format('l');
        } elseif ($days >= 7 && $days < 32) {
            $msg = $days . ' days ago';
            $withTime = false;
        } elseif ($days >= 32 && $days < 365) {
            $months = self::parse(Date('Y-m-d'))->diffInMonths($objDate);
            $msg = $months . (($months > 1) ? ' months ' : ' month ') . 'ago';
            $withTime = false;
        } else {
            $years = self::parse(Date('Y-m-d'))->diffInYears($objDate);
            $msg = $years . (($years > 1) ? ' years ' : ' year ') . 'ago';
            $withTime = false;
        }

        return ($withTime) ? $msg . ' at ' . $objDate->format('g:ia') : $msg;
    }
public static function lastUpdated ( $ date , $ withTime = true ) : string { $ objDate = self :: parse ( $ date ) ; $ date = self :: parse ( $ objDate ) -> format ( 'Y-m-d' ) ; $ days = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInDays ( self :: parse ( $ date ) ) ; if ( $ days == 0 ) { $ msg = 'today' ; } elseif ( $ days == 1 ) { $ msg = 'yesterday' ; } elseif ( $ days > 1 && $ days < 7 ) { $ msg = $ objDate -> format ( 'l' ) ; } elseif ( $ days >= 7 && $ days < 32 ) { $ msg = $ days . ' days ago' ; $ withTime = false ; } elseif ( $ days >= 32 && $ days < 365 ) { $ months = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInMonths ( $ objDate ) ; $ msg = $ months . ( ( $ months > 1 ) ? ' months ' : ' month ' ) . 'ago' ; $ withTime = false ; } else { $ years = self :: parse ( Date ( 'Y-m-d' ) ) -> diffInYears ( $ objDate ) ; $ msg = $ years . ( ( $ years > 1 ) ? ' years ' : ' year ' ) . 'ago' ; $ withTime = false ; } return ( $ withTime ) ? $ msg . ' at ' . $ objDate -> format ( 'g:ia' ) : $ msg ; }
Create a human readable representation of a typical "last_updated" DATETIME value.

@param  mixed $date
@param  boolean $withTime
@return string
Create a human readable representation of a typical last_updated DATETIME value .