Home › Forums › Front-end Issues › Date expiry issue › Reply To: Date expiry issue
I’m not too sure because I’m not completely sure how DateTime() works so this is an assumption.
When you call
$date = get_field('last_date', false, false);
$date = new DateTime($date);
there is not time so date/time is the value of the day at 00:00:00 (midnight)
But when you call
$currentdate = new DateTime();
this uses the default of “now” which has a time and because of the $currentdate will always be greater than $date except on the same day. Try setting $currentdate without a time formatted the same as what get_field() is returning.
$currentdate = new DateTime(date('Ymd'));
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!
ACF’s Repeater field is a versatile solution for repeating content in #WordPress.
— Advanced Custom Fields (@wp_acf) December 29, 2022
What’s your favorite use case for the Repeater field?
What’s the weirdest thing you’ve ever used it for?
Let us know!👇
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.