dateselectorbetweenprocesswire

Processwire Selector. Where now between start date and end date or now bigger than start date and end date is empty


I want select pages where now between date and end_date or now bigger than date and end_date is empty.

I have tried five variants:

$start = strtotime(date('Y-m-d') . " 00:00:00");
$results = $page->children("foo=(date<$start,date_end=''),bar=(date<$start,date_end>=$start),sort=-date,limit=12");

$start = strtotime(date('Y-m-d') . " 00:00:00");
$results = $page->children("date<$start,(date_end='',date_end>=$start),sort=-date,limit=12");

$start = strtotime(date('Y-m-d') . " 00:00:00");
$results = $page->children("date_end=''|date_end>=$start,date<$start,sort=-date,limit=12");

$start = strtotime(date('Y-m-d') . " 00:00:00");
$results = $page->children("!date_end|date_end>=$start,date<$start,sort=-date,limit=12");

$start = strtotime(date('Y-m-d') . " 00:00:00");
$results = $page->children("date_end>=$start|!date_end,date<$start,sort=-date,limit=12");

All this variants not worked for me and returned zero results.


Solution

  • The right way was:

    $results = $page->children("date<today, (date_end>today), (date_end=''), sort=-date, limit=12");
    

    You can use "today" in place of your timestamp.