Comparing two dates (ACF and current time)

I’m trying to compare two dates (the current date with an ACF datepicker one) to display specific content. What I’m trying to achieve is to display a phrase if the ACF date is lower than the current time (in few words if a service is expired). This is my code:

$dataScadenza = get_field('data_di_scadenza');
$currentDateTime = date('d.m.y');

if($dataScadenza = $currentDateTime) {

echo 'a href="'.get_field('link_esito').'"';
echo 'button class="vedi_esiti"VEDI ESITI/button';
echo '/a';

} else {

echo 'span class="ds_label"data scadenza/span';
echo 'div class="ds_date"'.get_field('data_di_scadenza').'/div';

}

where $dataScadenza is the ACF date and $currentDateTime is current date. Both variables have the same output (d.m.y).

What happens is that the comparison is applied only on day number and not on the entire date.

Anyone can help to solve the problem?

Thank you!

Topic advanced-custom-fields date comparison Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.