public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
public function date ( $ date , $ format = null ) { if ( $ this -> isEmptyDate ( $ date ) ) { return '' ; } $ isLocalizerFormat = in_array ( $ format , [ Localizer :: SHORT , Localizer :: LONG , Localizer :: VERBOSE ] ) ; if ( $ format && ! $ isLocalizerFormat ) { return $ this -> toDateTime ( $ date ) -> format ( $ format ) ; } if ( ! $ this -> localizer ) { return $ this -> toDateTime ( $ date ) -> format ( 'Y-m-d' ) ; } return $ this -> localizer -> date ( $ date , $ format ? : Localizer :: SHORT ) ; }
Format a date.

@param mixed  $date
@param string $format (optional)

@return string
Format a date .