Home › Forums › ACF PRO › Date Field – change div class based by date › Reply To: Date Field – change div class based by date
What is the date format of the date field?
In order to compare 2 dates the dates must be in the same format and that format must have the year first, month second and day last (“Ymd” or “Y-m-d” or “Y/m/d”). in the format you are using dmY
12-30-1900 (Dec 30, 1900) will always be greater than any other date combination for example 01-01-2021 (Jan 1, 2021), “01” is less than “12”
// unformatted date
$webinarDateUnformatted = get_sub_field('webinar-date', false, false);
$now = date('Ymd');
if ($webinarDateUnformatted < $now) {
// date is less than now
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.