Support

Account

Home Forums Add-ons Repeater Field Compare dates in rows against today Reply To: Compare dates in rows against today

  • Hi @phatoz

    I’m not sure I understand your query, so please forgive me if I’m wrong. Do you mean you want to check if the date you entered in the date field is within the range of 1 week (the past and future) from the current day? If that’s what you want, could you please try the following code?

    $today = date('Ymd');
    $last_week = $today-7;
    $next_week = $today+7;
    $date_field_value = get_field('date_picker', 85);
    
    if( ($date_field_value >= $last_week) && ($date_field_value <= $next_week) ){ 
        echo "id='active_week'";
    }

    Please keep in mind that you need to set the date field Return Format to “Ymd” on the field editor page.

    If that’s not what you want, could you please explain it and share some examples of the issue?

    Thanks 🙂