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
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.