Hi again,
I’m having difficulties achieving filterBy with a datetime field. I’ve seen the tutorials about filtering:
// fetch children with a date in the past
$items = $page->children()->filterBy('date', '<', time());
I don’t know where date
is taken from, but I have this in my blueprints:
activefrom:
label: Activation Date
type: datetime
activeuntil:
label: Active END Date
type: datetime
And therefore I want to filter the pages where now is between those two days, a common situation. I’m using
$page->children()->filterBy('activefrom', '<', time());
But I’m getting Object of class Field could not be converted to int
in kirby\vendor\getkirby\toolkit\lib\collection.php
,
specifically if(collection::extractValue($item, $field) < $value) continue;
My value is Activefrom: 2017-02-02 09:00:00
If I try to dump the value, it’s a real field with all the properties. Converting it to string actually returns 2017-02-02 09:00:00
, BUT the <
operator forces is to be converted to int
, which just fails.
Am I missing something?