How can I compare two dates in PHP?
The date is stored in the database in the following format
2011-10-2
If I wanted to
This works because of PHP's string comparison logic. Simply you can check...
if ($startdate < $date) {// do something}
if ($startdate > $date) {// do something}
Both dates must be in the same format. Digits need to be zero-padded to the left and ordered from most significant to least significant. Y-m-d
and Y-m-d H:i:s
satisfy these conditions.