如何在php中设置过期,无效?

I have a problem to define a product which have a expiry date. I want to set a product which it not valid (when $now = date("d-M-y") more than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));),

overdue (when $now = date("d-M-y") more than $due = date("d-M-y", strtotime('-30 days',strtotime($valid))); and $now = date("d-M-y") less than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));)

valid (when $now = date("d-M-y") less than $valid = date("d-M-y", strtotime('+'.$day.' days',strtotime($date)));)

This is my code :

if ($due > $now && $now > $valid )
{
$vendor ='<td style="color:red;text-align: center;font-weight: bold">'.$rowpur['ven_code'].' (Overdue)</td>';   
}
elseif ($due > $now && $now < $valid )
{
$vendor ='<td style="color:red;text-align: center;font-weight: bold">'.$rowpur['ven_code'].' (Not Valid)</td>'; 
}       
else 
{
$vendor = '<td style="text-align: center;font-weight: bold">'.$rowpur['ven_code'].'</td>';  
}

And the result like a screenshot :

enter image description here

But all that vendor code must be Not Valid

You cannot compare dates via the basic < and >. The reason being that they are objects. You can represent the dates by calling the timestamp() method on the object. This will return an integer which can be compared the classical way.