I have a script where i have a table that contains dates for supplies. Now there are alot of dates +- 600. Now what i want to do is to highligt all dates that will expire fr
Assuming you are using PHP 5.3 > , you can use diff to get the day difference between your date and +2 weeks and then decide if to apply the css class to the <td>
or not.
Example:
// get two weeks from now
$date_in_two_weeks = strtotime('+2 weeks');
$date_in_two_weeks = date("Y/m/d",$date_in_two_weeks);
// get the date to compare, from db or whatever you want
$date_to_compare = "2014/02/01";
// compare the date in your list to now + 2 weeks and then put the date difference into $days_difference
$date_from_list = new DateTime($date_to_compare);
$date_in_two_weeks = new DateTime($date_in_two_weeks);
$days_difference = $date_from_list->diff($date_in_two_weeks);
if ($days_difference->days > 14) {
$highlight_css_class = "highlight";
} else {
$highlight_css_class = "";
}
Now in your table, apply css class to the <td>
or wherever you want it.
<tr>
<td>A1</td>
<td>hamburger</td>
<td class="<?php echo $highlight_css_class;?>">2014-02-10</td>
</tr>
Of course in CSS create the .highlight
class with the styling you want.
.highlight {
background:#e1e1e1;
}