1
I have a column in the database which is in format DATE (Y-m-d)
.
In php code I recover this string and have to compare with the current date and this is the condition I am using:
$dtEntrega=date("Y-m-d",strtotime($row["dtEnterga"]));
$today = strtotime(date("Y-m-d"));
if($today>=$dtEntrega){
//Fazer algo
}
But this code always returns true, even if the delivery date is stored in the database with date in the future. Does anyone know where I’m going wrong or is something missing?
Edition: The question is not the same as the one quoted by the moderator because the result of that does not apply to my context.
Everything seems to be okay: 2016-05-30 and 2016-07-02. That’s why I don’t understand.
– zwitterion
The one sought by the class Datetime
– Leonardo
Hi John, it’s not the same question. I had already passed through it before asking. Note the answer that has 16 points. It’s exactly what I did and it’s not working.
if(strtotime($data1) > strtotime($data2))
. The answer that worked was Nelson’s. One has to pass to string and the other not.– zwitterion