Support

Account

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'"; }?>>