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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.