I am trying to work out how to highlight dates dragged from a MySQL db as per the following:
- If database date is today then echo in green
- If database date is tomorrow then echo in orange
- If database date is the day after tomorrow then echo in red
Does anyone have any ideas how I can do this?
I have tried the following but for some reason dates way in to the future are displayed in red. I'm not sure if the code I am using is the best way to achieve this.
$date=date("d/m/Y", strtotime($rows['collect_date'])); if ($date==date(("d/m/Y"), strtotime('+1 days')) && $rows['status']=='4') { echo "<span class='label label-danger1'>".$date."</span>"; } elseif ($date==date(("d/m/Y")) && $rows['status']=='4') { echo "<span class='label label-danger'>".$date."</span>"; } elseif ($date==date(("d/m/Y"), strtotime('+2 days')) && $rows['status']=='4') { echo "<span class='label label-warning'>".$date."</span>"; } elseif (strtotime($date) < strtotime('1 day ago') && $rows['status']=='4') { echo "<span class='label label-danger'>".$date."</span>"; } else { echo $date; } Custom CSS:
.label-danger1{ background-color: #FF6666; } Many thanks,
John