I want to compare two dates in PHP. One date is the date due, which is provided by the user, stored in a database and retrieved with PHP. The second is today's date.
$unixdue = strtotime($query['date_due']); //Converts the database integer to Unix date
$duestamp = date("dmY", $unixdue); //Converts the Unix date to dd-mm-yyyy
//If the due date is larger than today (i.e., after today), it's early.
if ($query['complete'] == 0 AND date("dmY") < $duestamp) {echo "Early";}
//If the due date is smaller than today (i.e., before today), it's late.
elseif ($query['complete'] == 0 AND date("dmY") > $duestamp) {echo "Late";}
//If the due date IS today, it's today.
elseif ($query['complete'] == 0 AND date("dmY") == $duestamp) {echo "Today";}
It works with dates that are today, but all the others return "Early" even if they are not early. Due to this I can't even tell if the rest is working at all.
I have tried comparing two Unix dates, but they include the time as well, when really I only want the date. If I compare two unix dates, I can't say if something is "Today".