Comparing two ISO8601 dates strings in PHP
<p>I need to compare (actually rank/sort) dates in a PHP script. The dates are ISO-8601 Date format i.e. </p>

<p><strong>YYYY-MM-DD</strong></p>

<p>I wrote a comparison function which splits the dates and compares by year/month/day. However, it seems this may be overkill and I could just as easily done a simple string comparison like:</p>

<pre><code>if ($date1 &lt; $date2)
   // do something
elseif( $date1 &gt; $date2)
   //do something else
else
   //do yet another thing
</code></pre>

<p>Is my assumption about (ISO-8601) Date string comparison correct - i.e. can I get rid of my function (to save a few clock cycles on the server), or is it safer to explicity do the comparison in a custom function?</p>
