Jump to content

Archived

This topic is now archived and is closed to further replies.

djanim8

Checking if a date is less than today...

Recommended Posts

I'm trying to see if a date pulled from the database is less than the current date.. I'm using this:

if ($row['date'] < date("Y-m-d")) {
'do stuff
} else {
'do other stuff
}

it doesn't seem to work.. how can I check to see if the date is older than today?

the format in the $row['date'] is yyyy-mm-dd (2006-05-22)

Share this post


Link to post
Share on other sites
[!--quoteo(post=376031:date=May 22 2006, 10:11 AM:name=djanim8)--][div class=\'quotetop\']QUOTE(djanim8 @ May 22 2006, 10:11 AM) [snapback]376031[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'm trying to see if a date pulled from the database is less than the current date.. I'm using this:

if ($row['date'] < date("Y-m-d")) {
'do stuff
} else {
'do other stuff
}

it doesn't seem to work.. how can I check to see if the date is older than today?

the format in the $row['date'] is yyyy-mm-dd (2006-05-22)
[/quote]

try this instead (keep in mind that you must compare them as timestamps in PHP):
[code]
if (strtotime($row['date']) < time()) {
  // do stuff
} else {
  // do other stuff
}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.