Adding +1 day to selectedDate in Editor instance for filtering
Adding +1 day to selectedDate in Editor instance for filtering
I'm filtering a datetime field like below which works great. Yet, is it possible to 'add' +1 day to the selectedDate e.g. in the where condition below?
...
Field::inst( 'date' )
->getFormatter( function ( $val, $data, $opts ) {
return date( 'Y-m-d', strtotime( $val ) );
} )
)
...
// Date Filter
->where( function ($x) {
if ( $_POST["selectedDate"] ) {
$x->where( 'date', $_POST["selectedDate"], '<=' );
}
} )
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Sure - can't you just modify the
$_POST["selectedDate"]
parameter? Use the PHPstrtotime
method perhaps and thendate()
to convert it back to IS8601 for the database.Allan
Thanks Allan ... that worked! Regards