Return to Snippet

Revision: 67071
at August 6, 2014 20:07 by dmkim


Initial Code
$files = scandir($directory);
 
   while (list($key,$filename)=each($files)) {
       $files[$key] = $directory.'/'.$filename;

       if ((is_dir($files[$key])) || ($filename=='.') || ($filename=='..'))
          unset($files[$key]);
   }
 
   $recent_files = array_values(array_filter($files,'filter_by_date'));
 
   uasort($recent_files, 'sort_by_date');

//------------------------------
function filter_by_date($file) {
 
  $three_days_ago = strtotime(date('d.m.Y'))-3*24*3600;
 
 
   if (filemtime($file)<$three_days_ago)
      return false;
 
   return true;
}
 
//----------------------------
function sort_by_date($a,$b) {
 
   return filemtime($a)-filemtime($b);
}

Initial URL

                                

Initial Description
Find files modified not earlier than 3 days ago

Initial Title
Find files modified not earlier than 3 days ago

Initial Tags

                                

Initial Language
PHP