Delete old files - an hour ago or more than an hour ago
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6411451/how-can-i-delete-files-older-than-1-hour">How can I delete files older than 1 hour?</a>  </p>
</blockquote>



<p>the code down below delete all files inside a folder called " Images ". No complains everything works as it should, but is there a way to <strong>only</strong> delete the file  which was created an hour ago or more then hour ago instead? Please show me how, I'm trying  to learn by doing, please. Try to re-use the same code down below for better understanding  and also to help users PHP programmer around the world</p>

<pre><code>&lt;?php
define('PATH', 'Images/');

function destroy($dir) {
    $mydir = opendir($dir);
    while(false !== ($file = readdir($mydir))) {
        if($file != "." &amp;&amp; $file != "..") {
            chmod($dir.$file, 0777);
            if(is_dir($dir.$file)) {
                chdir('.');
                destroy($dir.$file.'/');
                rmdir($dir.$file) or DIE("couldn't delete $dir$file&lt;br /&gt;");
            }
            else
                unlink($dir.$file) or DIE("couldn't delete $dir$file&lt;br /&gt;");
        }
    }
    closedir($mydir);
}
destroy(PATH);
echo 'all done.';
</code></pre>
