filterBy('date') or some such?

Is there a way yet to do something simple like ->filterBy('date') instead of having to loop through all the items and compare dates?

I built a plugin once to show the most recent items that aren’t future, and I guess I could do the same thing to show only future items (like for events). But it would be nice if something was built-in.

from the docs:

// fetch children with a date in the past
$items = $page->children()->filterBy('date', '<', time());

// fetch children with a date in the future
$items = $page->children()->filterBy('date', '>', time());

http://getkirby.com/docs/cheatsheet/pages/filterBy

2 Likes

Haha, I could’ve sworn I just looked at that page. Maybe I accidentally looked at findBy instead or something.

Thanks!

I just moved my answer/following-up question to a new topic: Filter by day (not seconds)