Im trying to figure out how to get Entries by date range, say I would like to get all Entries from one week back, or I would like to get all Entries from a specific month.

I find some Twig examples, but haven't successfully been able to translate them to php for use in my plugin.

Any help is much appreciated.

1 Answer 1


Ok, found an answer that made it a bit clearer: How do I get elements using getCriteria from a specific date?

Basically you can do this:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->postDate = '>'. date('Y-m-d', strtotime("-4 weeks"));
$result = $criteria->find();

To get Entries form a month back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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