title: How to delete all files in folder after specific time
body: <p>I am using this code to delete all files in folder </p>
  
  <pre><code>$dir = $_SERVER['DOCUMENT_ROOT'].'/upload/';
          $op_dir=opendir($dir);
          $x = 5; 
          $current_time = time();
          $difference = $current_time - $x;
  
          while($file=readdir($op_dir ))
           {
                   if($file != "." &amp;&amp; $file != ".." ){
                       var_dump($dir.$file);
                     unlink ($dir.$file);
                   }
          }
          closedir($dir);
  </code></pre>
  
  <p>But I need to do this action after specific time for example after 6 month all files in the folder should be deleted.I searched more but all codes are related to file creation date not generally specific time.</p>