public function parse(\DateTime $dateTime, $value)
    {
        $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
        $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';

        $options = [];

        if (preg_match($reverseMatchingRegExp, $value, $matches)) {
            $matches = $this->normalizeArray($matches);

            foreach ($this->transformers as $char => $transformer) {
                if (isset($matches[$char])) {
                    $length = \strlen($matches[$char]['pattern']);
                    $options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
                }
            }

            // reset error code and message
            IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);

            return $this->calculateUnixTimestamp($dateTime, $options);
        }

        // behave like the intl extension
        IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');

        return false;
    }
public function parse(\DateTime $dateTime, $value)
    {
        $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
        $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';

        $options = [];

        if (preg_match($reverseMatchingRegExp, $value, $matches)) {
            $matches = $this->normalizeArray($matches);

            foreach ($this->transformers as $char => $transformer) {
                if (isset($matches[$char])) {
                    $length = \strlen($matches[$char]['pattern']);
                    $options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
                }
            }

            // reset error code and message
            IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);

            return $this->calculateUnixTimestamp($dateTime, $options);
        }

        // behave like the intl extension
        IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');

        return false;
    }
public function parse ( \ DateTime $ dateTime , $ value ) { $ reverseMatchingRegExp = $ this -> getReverseMatchingRegExp ( $ this -> pattern ) ; $ reverseMatchingRegExp = '/^' . $ reverseMatchingRegExp . '$/' ; $ options = [ ] ; if ( preg_match ( $ reverseMatchingRegExp , $ value , $ matches ) ) { $ matches = $ this -> normalizeArray ( $ matches ) ; foreach ( $ this -> transformers as $ char => $ transformer ) { if ( isset ( $ matches [ $ char ] ) ) { $ length = \ strlen ( $ matches [ $ char ] [ 'pattern' ] ) ; $ options = array_merge ( $ options , $ transformer -> extractDateOptions ( $ matches [ $ char ] [ 'value' ] , $ length ) ) ; } } // reset error code and message IntlGlobals :: setError ( IntlGlobals :: U_ZERO_ERROR ) ; return $ this -> calculateUnixTimestamp ( $ dateTime , $ options ) ; } // behave like the intl extension IntlGlobals :: setError ( IntlGlobals :: U_PARSE_ERROR , 'Date parsing failed' ) ; return false ; }
Parse a pattern based string to a timestamp value.

@param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
@param string    $value    String to convert to a time value

@return int|false The corresponding Unix timestamp

@throws \InvalidArgumentException When the value can not be matched with pattern
Parse a pattern based string to a timestamp value .