<p>Ok, found an answer that made it a bit clearer:
<a href="https://craftcms.stackexchange.com/questions/8739/how-do-i-get-elements-using-getcriteria-from-a-specific-date/8747#8747">How do I get elements using getCriteria from a specific date?</a></p>

<p>Basically you can do this:</p>

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

<p>To get Entries form a month back.</p>

CC BY-SA 3.0
2016-01-15T13:31:19.717Z
2016-01-15T13:31:19.717Z
2017-04-13T12:51:00.253Z
ladrua
<p>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.</p>

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

<p>Any help is much appreciated.</p>

<plugin-development><search><elementcriteriamodel><postdate>
Get entries by date range from plugin
# Get entries by date range from plugin

(Asked by: username_0 on 2016-01-15)

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.

**Tags:** plugin-development, search, elementcriteriamodel, postdate

---

## 1 answers

### Answer by username_0 on 2016-01-15. Score: 4 | Accepted answer

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.


---

