comparing dates in php
<p>In the following php code, I am trying to show only those products from products.xml file that are stored in the last month. But my code does not work. Please help me in getting correct output. I also need to show products that are stored in the last 24 hours and last week.</p>

<pre><code>$current_month = date("m");
$last_month = date('m', strtotime(date('-m')." -1 month"));

$xml = simplexml_load_file("products.xml");

$products = array();
foreach ($xml-&gt;product as $product) {
   if ($product-&gt;date('m') == $last_month) {
      $products[] = array( 'name' =&gt; (string)$product-&gt;name,
                           'details' =&gt; (string)$video-&gt;details );
   }    
}
</code></pre>
