Adding +1 day to selectedDate in Editor instance for filtering

Adding +1 day to selectedDate in Editor instance for filtering

CapamaniaCapamania Posts: 233Questions: 81Answers: 5
edited September 2016 in Editor

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

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Sure - can't you just modify the $_POST["selectedDate"] parameter? Use the PHP strtotime method perhaps and then date() to convert it back to IS8601 for the database.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    Thanks Allan ... that worked! Regards

This discussion has been closed.