Support

Account

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.