PHP date comparison and strtotime
<p>Using WIndows, XAMPP 5.6.8 I am building a simple web app in HTML and PHP.</p>

<p>I would like to compare a date retrieved from a database with today's date. </p>

<p>I have a function that successfully returns a string value (in the UK date format <code>d-m-y</code>). </p>

<p>My code so far is;</p>

<pre><code>$expDate = get_api_data($id); // returns a string
var_dump($expDate); // this prints string(8) "31-12-19"
</code></pre>

<p>Using this <code>$expDate</code> value I would like to achieve something like;</p>

<pre><code>if (strtotime('d-m-y', $expDate) &gt; time()) { // if date &gt; than today
    echo 'date is greater than today';
}
elseif (strtotime('d-m-y', $expDate) &lt; time()) { // if date &lt; than today
    echo 'date is less than today';
}
else { 
    echo 'date not found';
}
</code></pre>

<p>Currently I am receiving <em>date is less than today</em> - even though the date is <code>31-12-19</code>. I'm not sure if I am approaching this the correct way?</p>

<p>Any help would be greatly appreciated as I have alreday spent a lot of time researching answers to no avail. </p>