I have a Craft 3 site. For some reason the before filter isn't working when pulling entries from a channel, but after does. This is not a data issue.
{% set start = "2 months ago"|date() %}
{% set end = "next week"|date() %}
{% set listings = craft.entries({
section: "tvListings",
limit: null,
with: "channel",
before: end
}).all() %}
For clarity the dates result in:
- Start: Feb 4, 2018
- End: Apr 9, 2018
And one of the example entries is definitely in that date range (April 2nd).
If I ditch the "before" and go "after: start" it does work. If I try to say "give me all entries before Apr 9, 2018", the "Thunderbirds are go" (or any other listings) do not show.
Surely I'm not doing something super stupid right?
I'm running Craft 3.0.2.
Thanks.
EDIT: I've started pulling apart the CMS to debug. EntryQuery->beforePrepare() builds the query that filters by date. Although the props before and after are set, once they're passed through Db::parseDateParam() it mutilates the dates and somehow comes out with "2017-12-31 11:00:00" for both - so no bloody wonder it's not working. If this is a date format thing for those props I'll update the answer.