I have the following code:
$data = date("Y-m-d");
$dataTr = implode(preg_match("~\/~", $data_vencimento) == 0 ? "/" : "-", array_reverse(explode(preg_match("~\/~", $data_vencimento) == 0 ? "-" : "/", $data_vencimento)));
if (strtotime($data) > strtotime($data_vencimento)):
echo "<font color='red'>$dataTr - Vencida</font>";
elseif(strtotime($data) == strtotime($data_vencimento)):
echo "<font color='yellow'>$dataTr</font>";
else:
echo "<font color='green'>$dataTr</font>";
endif;
It was my intention that if the $data
, which would be today was greater than the due date, the date should be highlighted in red, if it were the same as today it would be yellow and if it was smaller than green, but for some reason this is not happening, and all dates are turning green, and there are dates already past. I wonder where my error is.
PS: Dates are being compared in the American AAAA / MM / DD format, according to this OS question .