src/Form.php
public function expectDateTime( $name, $format, $options = null ) {
		$options = ( is_array( $options ) ) ? $options : [];
		$options['callback'] = function ( $value ) use ( $format ) {
			try {
				$date = \DateTime::createFromFormat( $format, $value );
				$formatErrors = \DateTime::getLastErrors();
				if ( $formatErrors['error_count'] == 0 &&
					$formatErrors['warning_count'] == 0
				) {
					return $date;
				}
			} catch ( \Exception $ignored ) {
				// no-op
			}
			return false;
		};
		return $this->expect( $name, \FILTER_CALLBACK, $options );
	}
public function expectDateTime( $name, $format, $options = null ) {
		$options = ( is_array( $options ) ) ? $options : [];
		$options['callback'] = function ( $value ) use ( $format ) {
			try {
				$date = \DateTime::createFromFormat( $format, $value );
				$formatErrors = \DateTime::getLastErrors();
				if ( $formatErrors['error_count'] == 0 &&
					$formatErrors['warning_count'] == 0
				) {
					return $date;
				}
			} catch ( \Exception $ignored ) {
				// no-op
			}
			return false;
		};
		return $this->expect( $name, \FILTER_CALLBACK, $options );
	}
public function expectDateTime ( $ name , $ format , $ options = null ) { $ options = ( is_array ( $ options ) ) ? $ options : [ ] ; $ options [ 'callback' ] = function ( $ value ) use ( $ format ) { try { $ date = \ DateTime :: createFromFormat ( $ format , $ value ) ; $ formatErrors = \ DateTime :: getLastErrors ( ) ; if ( $ formatErrors [ 'error_count' ] == 0 && $ formatErrors [ 'warning_count' ] == 0 ) { return $ date ; } } catch ( \ Exception $ ignored ) { // no-op } return false ; } ; return $ this -> expect ( $ name , \ FILTER_CALLBACK , $ options ) ; }
Add an input expectation for a DateTime object.

@param string $name Parameter to expect
@param string $format Expected date/time format
@param array $options Additional options
@return Form Self, for message chaining
@see DateTime::createFromFormat
Add an input expectation for a DateTime object .