php - Check if date is in range of multiple date ranges -


i have list of certificates have expiry date. trying show different colours depending on how far away expiry. need show red if expires in less 30 days (or has expired), amber if date between 60 , 30 days away , green if more 60 days. far have started working on +30 days part. far have following

<?php foreach($company_certificates $certificates):  $startdate = date('d-m-y'); $onemonth = date('d-m-y', strtotime('+30 days'));  ?>  <tr>     <td><?php echo $certificates->username ?></td>     <td><?php echo $certificates->certificate ?></td>     <td><?php echo $certificates->expiry_date ?></td>     <td><?php      //$onemonth = date($certificates->expiry_date, strtotime('-30 days'));     if ($date >= $certificates->expiry_date)     {         $expiry = '2'; //expired     }     else     {         if($certificates->expiry_date > $onemonth && $startdate < $certificates->expiry_date)          {             $expiry = '1';             //echo"1 month";         }         else         {             $expiry = '0';          }     }     echo '<img src="' . $this->config->base_url('assets/images/expiry_' . $expiry . '.png') . ' "/>';?></td></tr> <?php endforeach; ?> 

so far shows if certificate has expired, doesn't show correct expiry other certificates. point me in right direction problem killing me. thanks!

have @ datetime::diff interval, formatting simple


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -