getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Extended filtering by date #563

Closed nilshoerrmann closed 4 years ago

nilshoerrmann commented 4 years ago

It would be great, if Kirby's date filtering capacity were enhanced. Currently, we are able to filter by dates like this (excluding custom filter functions):

$pages->filterBy('date',` '>', '2020-01-01');

The filter methods only allows string comparisons and thus doesn't allow for relative date definitions PHP is able to read, e. g. now or +6 months. Following this conversion on Slack, it would be nice to either add extra date comparisons to the core like

$pages->filterBy('date', 'date >', 'now');
$pages->filterBy('date', 'date <=', '+6 months');

or a specialized filter method like

$pages->filterByDate('date', '>', 'now');
$pages->filterByDate('date', '<=', '+6 months');

or a helper to convert relative date to strings like

$pages->filterBy('date', '>=', ymd('+6 months'));

where ymd() converts any time string to Y-m-d format.

bastianallgeier commented 4 years ago