0
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;
My intention was that I should marry $data
, that today would be longer than the due date, the date should be highlighted in red, if it was equal to today it would be in yellow and if it was smaller it would be in green, but for some reason this is not happening, and all dates are turning green, and there are expired dates. I wonder where my mistake lies.
P.S: The dates are being compared in American format YYYY/MM/DD, according to data from this question of the OS.
How’s the value of
$data_vencimento
?– Marcelo de Andrade