Support

Account

Home Forums ACF PRO Comparing current date with ACF date Reply To: Comparing current date with ACF date

  • In order to compare dates the way your are doing it the date needs to have year first, then month, then day. ACF stores the date in the DB in the format “Ymd”

    
    // supply 3rd argument of false to get unformatted date
    $dataScadenza = get_field('data_di_scadenza', false, false);
    // use the same date format for the current date
    $currentDateTime = date('Ymd');
    
    if($dataScadenza <= $currentDateTime) {
      // ......