Home › Forums › ACF PRO › Group CPT in years by using ACF date field › Reply To: Group CPT in years by using ACF date field
usort($posts, function($a, $b) {
$dateA = get_field('acc_aanvangsdatum', $a->ID);
$dateB = get_field('acc_aanvangsdatum', $b->ID);
return strtotime($dateB) - strtotime($dateA);
});
“d/m/Y” is not an valid date format for strtotime()
https://www.php.net/manual/en/datetime.formats.php
strtotime() should be interpreting “d/m/Y” as “m/d/Y” so the return should still be within the “Year”, so I’m not sure why it would be an issue, but it’s the only thing that I can see to cause it.
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.