lundi 11 juin 2018

Display short expiry items with if condition

I am using SQL date format to display short expiry items in warning label as following.

Is it works outside of query?

if("STR_TO_DATE( '$expire', '%Y-%m' ) BETWEEN CURDATE() AND DATE_ADD( CURDATE(), INTERVAL 3 MONTH)")
{
     $display_date = "<label class='label label-warning'> $expire </label>";
}elseif("STR_TO_DATE( '$expire', '%Y-%m' ) <= DATE(now())")
 {
     $display_date = "<label class='label label-danger'> $expire </label>";

}else{
     $display_date = "<label class='label label-success'> $expire </label>";

 }

Aucun commentaire:

Enregistrer un commentaire