public function humanReadable(bool $returnDateAndTime = true): string
    {
        $current = new Dates;
        $diff    = parent::diff($current);
        
        $parsedTxt = new class {
            public $date = '';
            public $time = '';
        };

        if ($current == $this) {
            //Now
            $this->humanDateNow($parsedTxt);
        } elseif (
            $this->humanDateIsYesterdayOrTomorrow($diff, $current) === true
        ) {
            if ($diff->invert === 0) {
                $this->humanDateYesterday($parsedTxt); //Yesterday
            } else {
                $this->humanDateTomorrow($parsedTxt); //Tomorrow
            }
        } elseif ($diff->days === 0) {
            //Today
            $this->humanDateToday($parsedTxt, $diff);
        } else {
            $this->humanDateOther($parsedTxt, $current);
        }

        $txtReturned = $parsedTxt->date;
        if ($returnDateAndTime === true && $parsedTxt->time !== '') {
            $txtReturned .= $parsedTxt->time;
        }

        return $txtReturned;
    }
public function humanReadable(bool $returnDateAndTime = true): string
    {
        $current = new Dates;
        $diff    = parent::diff($current);
        
        $parsedTxt = new class {
            public $date = '';
            public $time = '';
        };

        if ($current == $this) {
            //Now
            $this->humanDateNow($parsedTxt);
        } elseif (
            $this->humanDateIsYesterdayOrTomorrow($diff, $current) === true
        ) {
            if ($diff->invert === 0) {
                $this->humanDateYesterday($parsedTxt); //Yesterday
            } else {
                $this->humanDateTomorrow($parsedTxt); //Tomorrow
            }
        } elseif ($diff->days === 0) {
            //Today
            $this->humanDateToday($parsedTxt, $diff);
        } else {
            $this->humanDateOther($parsedTxt, $current);
        }

        $txtReturned = $parsedTxt->date;
        if ($returnDateAndTime === true && $parsedTxt->time !== '') {
            $txtReturned .= $parsedTxt->time;
        }

        return $txtReturned;
    }
public function humanReadable ( bool $ returnDateAndTime = true ) : string { $ current = new Dates ; $ diff = parent :: diff ( $ current ) ; $ parsedTxt = new class { public $ date = '' ; public $ time = '' ; } ; if ( $ current == $ this ) { //Now $ this -> humanDateNow ( $ parsedTxt ) ; } elseif ( $ this -> humanDateIsYesterdayOrTomorrow ( $ diff , $ current ) === true ) { if ( $ diff -> invert === 0 ) { $ this -> humanDateYesterday ( $ parsedTxt ) ; //Yesterday } else { $ this -> humanDateTomorrow ( $ parsedTxt ) ; //Tomorrow } } elseif ( $ diff -> days === 0 ) { //Today $ this -> humanDateToday ( $ parsedTxt , $ diff ) ; } else { $ this -> humanDateOther ( $ parsedTxt , $ current ) ; } $ txtReturned = $ parsedTxt -> date ; if ( $ returnDateAndTime === true && $ parsedTxt -> time !== '' ) { $ txtReturned .= $ parsedTxt -> time ; } return $ txtReturned ; }
Transform a date to a human readable format

@param boolean $returnDateAndTime (default true) True to return date and
time concatenated with a space. False to have only date.

@return string
Transform a date to a human readable format