Date function and DB question

liunx

Guest
Say I have a page that queries a database, it returns certain data and then the date. Is it possible to check to see if the date is todays date, and then display it differently from the older dates?date("Y-m-d", time());

This will give you today's date in the form YYYY-MM-DD which is usually how dates are stored in the db.
So if you have the date in an array extracted from the db, you could just do something like


$todaysDate = date("Y-m-d", time());

if($row["date"] == $todaysDate) {
echo "<EM>".$row["date"]."</EM>\n";
} else {
echo $row["date"]."\n";
}


If this doesn't help you, you can surely figure something out by looking at function.date.php (<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.date.php">http://www.php.net/manual/en/function.date.php</a><!-- m -->) in the PHP manual.you don't need time in there

$todaysDate = date("Y-m-d");

that will work just fineI see. I thought date() had to get the current timestamp, and then format it with the first string. I guess I just did a stupid mistake again, I should really stop trying to help people around here.Wow, thanks. You guys are great at this.... oh the aspirations.
 
Back
Top