Home › Forums › Add-ons › Repeater Field › Compare dates in rows against today › Reply To: Compare dates in rows against today
Yes, the $today was declared further up in the code so I didn’t include it in my snippet.
I ended up using this code and it seems to work perfectly.
$treasure_bag_date = get_sub_field('treasure_bag_date');
$today = date('Ymd');
$next_week = date_create($treasure_bag_date);
$next_week = date_add($next_week, date_interval_create_from_date_string('7 days'));
$next_week = date_format($next_week, 'Ymd');?>
<?php // set #active_week to current week ?>
<tr <?php if( ($today >= $treasure_bag_date) && ($today <= $next_week) ){ echo "id='active_week'"; }?>>
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.