src/Pattern/StdPatterns/DatePattern.php
public function toUrl($rawData): string
    {
        $data = $this->processRawData($rawData);

        if (\is_object($data) && $data instanceof \DateTimeInterface) {
            return $data->format(static::DATE_FORMAT);
        }

        if (\is_int($data)) {
            return (new \DateTime())->setTimestamp($data)->format(static::DATE_FORMAT);
        }

        if (\is_string($data) && $this->match($data)) {
            $sData = (string) $data;
            if ($this->checkDate($sData)) {
                return $sData;
            }
        }

        throw $this->newInvalidToUrl($data);
    }
public function toUrl($rawData): string
    {
        $data = $this->processRawData($rawData);

        if (\is_object($data) && $data instanceof \DateTimeInterface) {
            return $data->format(static::DATE_FORMAT);
        }

        if (\is_int($data)) {
            return (new \DateTime())->setTimestamp($data)->format(static::DATE_FORMAT);
        }

        if (\is_string($data) && $this->match($data)) {
            $sData = (string) $data;
            if ($this->checkDate($sData)) {
                return $sData;
            }
        }

        throw $this->newInvalidToUrl($data);
    }
public function toUrl ( $ rawData ) : string { $ data = $ this -> processRawData ( $ rawData ) ; if ( \ is_object ( $ data ) && $ data instanceof \ DateTimeInterface ) { return $ data -> format ( static :: DATE_FORMAT ) ; } if ( \ is_int ( $ data ) ) { return ( new \ DateTime ( ) ) -> setTimestamp ( $ data ) -> format ( static :: DATE_FORMAT ) ; } if ( \ is_string ( $ data ) && $ this -> match ( $ data ) ) { $ sData = ( string ) $ data ; if ( $ this -> checkDate ( $ sData ) ) { return $ sData ; } } throw $ this -> newInvalidToUrl ( $ data ) ; }
Convert passed argument to date in format YYYY-mm-dd

@param int|string|\DateTimeInterface $rawData

@return string

@throws PatternException
Convert passed argument to date in format YYYY - mm - dd