-1

I have followed all the method shown in other posts but none of them are working I have tried from this post the strtotime("2067-05-13") method but it is not working for my purpose. Please let me know how to compare two dates when one of the dates is 50 years from today. I've also tried using the methods date() and date_create(). I'm using PHP 5.4. Thanks in advance.

Here is my sample code

$expDate = strtotime($expirationDate);
$eff = strtotime($row['effective_date']);
$isEffectiveDateInRange=$expDate>$eff?true:false;

1 Answers1

3

Try this:

$now = new \DateTime();
$later = new \DateTime('2067-05-13');

var_dump($now < $later);

Note It doesn't matter what the difference is, you can always compare date objects just like that.

For reference, see:

For an example, see:

localheinz
  • 9,179
  • 2
  • 33
  • 44