public function transform($date)
    {
        if (!$date instanceof DateTime) {
            $date = new DateTime($date);
        }

        $current = new DateTime('now');

        if ($this->isToday($date)) {
            return $this->trans('Today');
        }

        if ($this->isYesterday($date)) {
            return $this->trans('Yesterday');
        }

        if ($this->isTomorrow($date)) {
            return $this->trans('Tomorrow');
        }

        if ($this->isNextWeek($date)) {
            return $this->trans('Next %weekday%', [ '%weekday%' =>  $date->format('l') ]);
        }

        if ($this->isLastWeek($date)) {
            return $this->trans('Last %weekday%', [ '%weekday%' => $date->format('l') ]);
        }

        if ($this->isThisYear($date)) {
            return $date->format('F j');
        }

        return $date->format('F j, Y');
    }
public function transform($date)
    {
        if (!$date instanceof DateTime) {
            $date = new DateTime($date);
        }

        $current = new DateTime('now');

        if ($this->isToday($date)) {
            return $this->trans('Today');
        }

        if ($this->isYesterday($date)) {
            return $this->trans('Yesterday');
        }

        if ($this->isTomorrow($date)) {
            return $this->trans('Tomorrow');
        }

        if ($this->isNextWeek($date)) {
            return $this->trans('Next %weekday%', [ '%weekday%' =>  $date->format('l') ]);
        }

        if ($this->isLastWeek($date)) {
            return $this->trans('Last %weekday%', [ '%weekday%' => $date->format('l') ]);
        }

        if ($this->isThisYear($date)) {
            return $date->format('F j');
        }

        return $date->format('F j, Y');
    }
public function transform ( $ date ) { if ( ! $ date instanceof DateTime ) { $ date = new DateTime ( $ date ) ; } $ current = new DateTime ( 'now' ) ; if ( $ this -> isToday ( $ date ) ) { return $ this -> trans ( 'Today' ) ; } if ( $ this -> isYesterday ( $ date ) ) { return $ this -> trans ( 'Yesterday' ) ; } if ( $ this -> isTomorrow ( $ date ) ) { return $ this -> trans ( 'Tomorrow' ) ; } if ( $ this -> isNextWeek ( $ date ) ) { return $ this -> trans ( 'Next %weekday%' , [ '%weekday%' => $ date -> format ( 'l' ) ] ) ; } if ( $ this -> isLastWeek ( $ date ) ) { return $ this -> trans ( 'Last %weekday%' , [ '%weekday%' => $ date -> format ( 'l' ) ] ) ; } if ( $ this -> isThisYear ( $ date ) ) { return $ date -> format ( 'F j' ) ; } return $ date -> format ( 'F j, Y' ) ; }
Transforms the given date into a human-readable date.

@param DateTime|string $date Input date.

@return string Human-readable date.
Transforms the given date into a human - readable date .