php check 1 day before the date expires [closed]

-1

I'm creating a project where I need to inform users 1 day before the date expires.

I created code but .. it does not work.

 $prev_expire_date = date('Y-m-d', strtotime($ads_details['ads_featured'] .' -1 day'));

 if($prev_expire_date) {

    echo "<a href='#' class='btn btn-sm btn-info-filled btn-rounded no-margin'><span>Renovar?</span></a></span></h4>"; 
 } else {
   echo "<a href='#' class='btn btn-sm btn-info-filled btn-rounded no-margin'><span>Destacado</span></a></span></h4>";  
}
    
asked by anonymous 23.07.2018 / 03:46

1 answer

1

Come on:

 $hora1 = new DateTime('2018-07-22 11:47:24');
 $hora2 = new DateTime('2018-07-23 11:47:24');

  $intervalo = $datetime1->diff($hora2);

  if($intervalo->format("%D") >= "01"){
    echo "<a href='#' class='btn btn-sm btn-info-filled btn-rounded no-margin'><span>Renovar?</span></a></span></h4>";
  }else{
    echo "<a href='#' class='btn btn-sm btn-info-filled btn-rounded no-margin'><span>Destacado</span></a></span></h4>";
  }

I hope I have helped

    
23.07.2018 / 20:37