djanim8 Posted May 22, 2006 Share Posted May 22, 2006 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 Link to comment https://forums.phpfreaks.com/topic/10183-checking-if-a-date-is-less-than-today/ Share on other sites More sharing options...
obsidian Posted May 22, 2006 Share Posted May 22, 2006 [!--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] Quote Link to comment https://forums.phpfreaks.com/topic/10183-checking-if-a-date-is-less-than-today/#findComment-37947 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.