Comparing curent date with date from database
<p>I need help with my script that is comparing current date with date that is entered in database, the thing that I wont to do is get alert message when the date from database pass the current date, and alert if the date from database is near the current date. The problem with my code comes when the month is different. Script works when comparing current day and day from database date, but when the month is different for example 02.05.2012 and 28.04.2012 the script is acting as if the 28.04.2012 is yet to come, he is not taking the month in consideration. I hope the question is clear. Here is the coding so far. Any ideas?  </p>

<pre><code>$vrjedi_do_osobna = $row['vrjedi_do_osobna'];

$current_date = date('d.m.Y');

$query = mysql_query("SELECT * from albums where vrjedi_do_osobna = '$current_date'
                                AND $id = 'userid'");




    $ime = $row['dosjename'];
    $prezime = $row['dosje_prezime'];
    $diff = abs(strtotime($current_date) - strtotime($vrjedi_do_osobna));

    $years = floor($diff / (365*60*60*24));
    $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
if($current_date &lt; $vrjedi_do_osobna &amp;&amp; $days &lt; 10 &amp;&amp; $days &gt; 0 &amp;&amp; $years &lt; 1 &amp;&amp; $months &lt; 1)
    {
echo"&lt;font face='gregorian' size='2'&gt;";
   printf("&amp;nbsp;&lt;img src='slike_izgled/pj_sat.png' width='20' height='30'/&gt;&amp;nbsp;Osobna  iskaznica radnika $ime $prezime ističe za %d dana\n", $days);
echo"&lt;/font&gt;&lt;br&gt;";
    }
    if ($vrjedi_do_osobna &lt;= $current_date)
                    {                                           
    echo "                            

&amp;nbsp;&lt;img src='slike_izgled/usklik.gif' width='25' height='25'&gt;&amp;nbsp;&lt;font face='gregorian' size='2'&gt;Osobna iskaznica radnika $ime $prezime-a je istekla!&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href='viewdosje.php?album=".$row['ideo']."'&gt;Pregled dosjea&lt;/a&gt;&lt;br&gt;

    "; 
// Do something

}
</code></pre>
