Support

Account

Home Forums ACF PRO Date Picker comparing two dates Reply To: Date Picker comparing two dates

  • Hi Simov,
    Find my code. Not sur it’s the cleanest way but it works.
    I use ‘specials’ CPT and i want display them only is the date is valid.

    
    <?php 
    $datedeb = get_field('debut-promo', false, false);
    $datefin = get_field('fin-promo', false, false);
    $today = strtotime(date('Ymd'));
    $promoend = strtotime($datefin);
    $datedeb = new DateTime($datedeb);
    $datefin = new DateTime($datefin);
    ?>			
         <?php if ($promoend >=$today): ?>
              // your code here
         <?php endif; ?>	
    

    Hope that will help you.
    cheers,
    Pierre-Yves