从SQL检索到的PHP日期的比较运算符无法正常工作

I've created an If an Else Statement but it doesn't work properly. I have some dates within my SQL which have been retrieved and stored in variables using PHP.

I'm comparing the current date with the dates from the database but for some reason, it thinks for example that 29-09-2015 if LESS THAN 31-01-2015.

I can understand that the format could be the issue d,m,Y but I thought I'd corrected that already. Here's the code:

$today = date('d-m-Y');
$date = $row['respondby'];
$euDate= date("d-m-Y", strtotime($date));

<?php 


if($today < $euDate){                                                           echo "<td>". $today." is less than ". $euDate ."</td>";
}
else{
echo"<td>Lost somewhere in between ?!?!?! :S </td>";
}
?>

As a result it prints 29-09-2015 is less than 30-06-2015

today's date was 29-09-2015 and one of the dates was in the data was this one as shown.

Thank you everyone that helps.

Comparison of dates as strings uses lexicographical order, hence your result is "correct".

Instead of d-m-Y format, try to use Y-m-d, this guarantees proper ordering.

$today = date('Y-m-d');
$date = $row['respondby'];
$euDate= date("Y-m-d", strtotime($date));
if($today < $euDate) { [...] }

Or, you can use Date objects instead:

$today = new Date('now');
$euDate= new Date($row['respondby']);
if($today < $euDate) { [...] }