Compare dates from different months

Asked

Viewed 35 times

0

Good,

I am using the following code to calculate whether one date is less than the other :

$dferiasinicial =date("d/m/Y",strtotime($_POST['dferiasinicial']));
$da = date("d/m/Y");

if($dferiasinicial <= $da){

return true;
else{
return false;
}

If the value of $dferiasinicial for 16/05/2019 and the value of $da for 16/04/2019 the function will return me false because it is only taking into account the days.

Can someone explain to me why and/or give me a solution?

  • thank you very much!

1 answer

-1

Try something like this

$dferiasinicial->diff($da)->d

Browser other questions tagged

You are not signed in. Login or sign up in order to post.