2

I need to display entries from the past 12 months. I'd like to create an entry query and set the timeframe of the entries I need.

Jeff Irwin
  • 150
  • 5

1 Answers1

2

I used the after parameter in my query.

{% set query = craft.entries({
    after: now|date_modify('5:00 -12 months')
}).all() %}

I'm grabbing todays date, then modifying with the date_modify filter. The 5:00 string makes sure it changes at the same time everyday.

I got the usage of date_modify from carlcs's answer here: How to only show entries older than 12 months

Jeff Irwin
  • 150
  • 5