I have a list of certificates that have an expiry date. I am trying to show different colours depending on how far away they are from expiry. I need to show red if it expires in less than 30 days (or has already expired), amber if the date is between 60 and 30 days away and green if more than 60 days. So far I have only started working on the +30 days part. So far I have the following
<?php foreach($company_certificates as $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 it shows if the certificate has expired, but it doesn't show the correct expiry for the other certificates. Could anyone point me in the right direction as this problem is killing me. Thanks!