I'm running a small script that takes a string from a database and then I'm trying to compare it to the server date, to see if it's in the future or past. I've managed this amount in my coding but I'm a bit stump on how to highlight if it's one week away etc.. E.g. I'm building a system for highlight stock being out of date, and I need to be able to give a weeks notice in the system, so I need to compare the date to the current server time and add like 7 days.. then will it be out of date.. etc.
Here's what I have, if anyone can help that'd be great.
Code: Select all
<td style="font-size:11px"><?php echo $row['Purchase_Date']; ?></td> <?php $sbd=$row['Sell_By_Date']; if (strtotime($sbd) < time()) echo '<td style="font-size:11px; background-color:#FF6666; font-weight:bold"> OUT OF DATE </td>'; else if (strtotime($sbd) > time()) echo '<td style="font-size:11px">' .$sbd.' </td>'; ?>