Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    You can do, but the easiest way is to simply compare the start and dates. E.g., to check if and event starts and ends on the same day:

    if( eo_get_the_start( 'Y-m-d' ) == eo_get_the_end( 'Y-m-d' ) ){
        //Same day
    }else{
        //Different days
    }
    Thread Starter emmafull

    (@emmafull)

    Ah brilliant, would there be any issue to also add in eo_reoccurs() within the conditional statement?

    I’m also wondering if I can include the time within the conditional statement as well or if that might be taking it too far?!

    Plugin Author Stephen Harris

    (@stephenharris)

    No, you can use eo_reoccurs() too:

    if( eo_reoccurs() && ( eo_get_the_start( 'Y-m-d' ) == eo_get_the_end( 'Y-m-d' ) ) ){
        //Same day & recurring event
    }else{
        //Different days or not recurring
    }

    You can also do nested conditional statements if that is required.

    Regarding time, eo_get_the_start() and eo_get_the_end() both expect a datetime format string (see php date). So you can include a date or time component or both. That conditionally is just comparing two strings (the date as a string).

    Additionally if you do you $start = eo_get_the_start( DATETIMEOBJ ) you can get the datetime back as a DateTime object, which you can do all sorts of things with ;).

    Thread Starter emmafull

    (@emmafull)

    Fantastic, I’ve managed to use that to sort out some conditional statements and can just see how I can create a different date/time appearance for events that will reoccur daily – I think!

    Many thanks for the help 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Conditional statements based on event duration?’ is closed to new replies.