<p>You were close, you can set a <code>postDate</code> param on your <code>craft.entries</code> criteria model. And the Twig filter <a href="http://twig.sensiolabs.org/doc/2.x/filters/date_modify.html" rel="noreferrer"><code>date_modify</code></a> helps you to get the DateTime from 12 months ago.</p>

<pre><code>{% set timeAgo = now|date_modify('5:00 -12 months') %}
{% set postDateParam = '&lt; ' ~ timeAgo|date('U') %}

{% set entries = craft.entries.section('news').postDate(postDateParam) %}
</code></pre>

CC BY-SA 3.0
2017-02-18T23:37:51.470Z
Just to understand your code:  {% set timeAgo = now|date_modify('5:00 -12 months') %} sets timeAgo to now(5 o'clock) - 12 months  or what does the 5:00 stand for?
Rattikarl
CC BY-SA 3.0
2017-02-19T11:07:07.153Z
Yes, exactly. Set the time to 5 a.m. then go back 12 months. This makes sure that the page changes once per day (at 5 a.m.). See PHP docs for all the possible relative time formats http://php.net/manual/en/datetime.formats.relative.php
carlcs
CC BY-SA 3.0
2017-02-16T22:34:57.490Z
2017-02-16T22:41:41.947Z
2017-02-16T22:41:41.947Z
carlcs
<p>I want to build an archive template where only entries older than 12 months show up.
Is there an clean and easy way to do so? I only have strange calculations in mind.
Something like this would be nice :)</p>

<pre><code>{% for entry in craft.entries.section('news') if entry.postDate &gt; 12monthsago %}
{% endfor %}
</code></pre>

<templating><postdate>
How to only show entries older than 12 months
# How to only show entries older than 12 months

(Asked by: username_0 on 2017-02-16)

I want to build an archive template where only entries older than 12 months show up.
Is there an clean and easy way to do so? I only have strange calculations in mind.
Something like this would be nice :)
{% for entry in craft.entries.section('news') if entry.postDate > 12monthsago %}
{% endfor %}

**Tags:** templating, postdate

---

## 1 answers

### Answer by username_1 on 2017-02-16. Score: 7 | Accepted answer

You were close, you can set a postDate param on your craft.entries criteria model. And the Twig filter date_modify helps you to get the DateTime from 12 months ago.
{% set timeAgo = now|date_modify('5:00 -12 months') %}
{% set postDateParam = '< ' ~ timeAgo|date('U') %}

{% set entries = craft.entries.section('news').postDate(postDateParam) %}

> **Comments:**
> **username_0**: Just to understand your code:  {% set timeAgo = now|date_modify('5:00 -12 months') %} sets timeAgo to now(5 o'clock) - 12 months  or what does the 5:00 stand for?  
> **username_1**: Yes, exactly. Set the time to 5 a.m. then go back 12 months. This makes sure that the page changes once per day (at 5 a.m.). See PHP docs for all the possible relative time formats http://php.net/manual/en/datetime.formats.relative.php  

---

