Support » Plugin: AM Events » Filter event list by date

Viewing 1 replies (of 1 total)
  • Plugin Author Atte Moisio

    (@moisture)

    Hi,

    You can specify the start and end date of the month and do a meta_query for events that are between those dates.

    Get the start and end dates (requires php 5.3):

    $startDate = new DateTime('first day of january');
    $endDate = new DateTime('last day of january');
    $endDate->setTime(23, 59, 59);
    
    $start = startDate->format(am_get_default_date_format());
    $end = endDate->format(am_get_default_date_format());

    Use them in the meta_query:

    'meta_query' => array(
        array(
            'key' => 'am_startdate',
            'value' => array($start, $end),
            'compare' => "BETWEEN"
    	),
    )

    I have not tested the code above, so prepare for some typos 🙂

    If you’re using php 5.2 or older, check out http://stackoverflow.com/questions/4702696/timestamps-of-start-and-end-of-month on how to get the dates.

Viewing 1 replies (of 1 total)
  • The topic ‘Filter event list by date’ is closed to new replies.