Continuing the discussion from filterBy('date') or some such?:
The filterBy() examples from the docs filter items by seconds because time() returns the current time measured in the number of seconds since the Unix Epoch.
So practically every item of the current day is an item of the past.
I wonder how to filter items by day.
Can you help me with the following requirements?
- items from today
- items from today or later
- items from tomorrow or later
- items from yesterday or earlier
I think you could start by replace time()
with date('Ymd')
.
// fetch children with a date in the past
$items = $page->children()->filterBy('date', '>=', date('Ymd'));
Now you compare a timestamp with a YYYYMMDD date. This does not work. Of course not.
Is it possible to format the 'date'
part with custom date parameters so you can compare it date('Ymd')
?
Or do you have any other ideas?