public function valid_date(string $str = null, string $format = null): bool
	{
		if (empty($format))
		{
			return (bool) strtotime($str);
		}

		$date = \DateTime::createFromFormat($format, $str);

		return (bool) $date && \DateTime::getLastErrors()['warning_count'] === 0 && \DateTime::getLastErrors()['error_count'] === 0;
	}
public function valid_date(string $str = null, string $format = null): bool
	{
		if (empty($format))
		{
			return (bool) strtotime($str);
		}

		$date = \DateTime::createFromFormat($format, $str);

		return (bool) $date && \DateTime::getLastErrors()['warning_count'] === 0 && \DateTime::getLastErrors()['error_count'] === 0;
	}
public function valid_date ( string $ str = null , string $ format = null ) : bool { if ( empty ( $ format ) ) { return ( bool ) strtotime ( $ str ) ; } $ date = \ DateTime :: createFromFormat ( $ format , $ str ) ; return ( bool ) $ date && \ DateTime :: getLastErrors ( ) [ 'warning_count' ] === 0 && \ DateTime :: getLastErrors ( ) [ 'error_count' ] === 0 ; }
Checks for a valid date and matches a given date format

@param string $str
@param string $format

@return boolean
Checks for a valid date and matches a given date format