1

I am trying to search for specific matrix blocks by date like so:

$criteria = craft()->elements->getCriteria(ElementType::MatrixBlock);

$criteria->ownerId = $entry->id;

$criteria->type = 'myMatrixBlockType';

$criteria->myMatrixBlockDateField = "2016-06-01 04:00:00";

$criteria->limit = 10;

$blocks = $criteria->find();

It seems that no matter what format the date is, all blocks from the matrix field in the entry are returned. Any help is appreciated!

1

You need to add a fieldId param to make Craft join the content table.

$criteria->fieldId = $matrixFieldId;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.