PHP: Problem with date determination

Hey,

I’m trying to mark specific entries that are being fetched out of my database with a color, that are dating exactly 3 days ago from a submitted date. For instance, user has applied for something, and his event is on the 01/02/2011, - if the date is 04/02/2011, the entry on the website (that is always being fetched out of the database) should appear in a certain color. I’ve already figured out how to do that, the only problem I have, - how would that work with the date()-function?


$eventDate = '2011-02-01';

if($eventDate == date('Y-m-d', strtotime('-3 days'))) {
    $class = 'class="three_days_ago"';
}
else {
    $class = '';
}
echo "<p $class>$eventDate</p>"

The paragraph will have a CSS class of three_days_ago if that’s true.

Thanks, - I got the idea now, the function strtotime is something I was looking for. :slight_smile: