I have a simple thing I’m trying to solve.
I have a date stored in a table, and I’m comparing it to a php generated date.
ie:
if($row['start_date'] < date("Y-m-d")) {
// table stored date larger than php date
echo 'hi';
} else {
// php date larger than table stored date
echo 'bye';
}
This seems ok to me, but
if $row['start_date'] === '2011-09-13' AND date("Y-m-d") === '2011-09-15'.
I end up with:
hi
This could be one of those twilight moments where I think left is right and a greater than symbol is actually a less than. So please help me – why doesn’t this work?
If
$row['start_date'] = '2011-09-13'anddate("Y-m-d") = '2011-09-15', then your PHP date is greater than the row’s date and thus theifis true, after all'2011-09-13'is “smaller (<)” than'2011-09-15'. Flip your<to>and you’ll be fine.