I use the following function to get all the images from a dir, but instead of putting all the images in the $files array, I would like to tweak it, so it only takes the images uploaded between 15:00:00 and 15:59:59 – today.
function get_files($images_dir,$exts = array('jpg')) {
$files = array();
if($handle = opendir($images_dir)) {
while(false !== ($file = readdir($handle))) {
$extension = strtolower(get_file_extension($file));
if($extension && in_array($extension,$exts)) {
$files[] = $file;
}
}
closedir($handle);
}
return $files;
}
But I can’t figure out how to do it, and even less how to do it efficient since the folder has around 9000 images. Anyone can point me in the right direction?
Note: All the images are named like this “Snapshot-20110910-103242.jpg” with date-time.
1 Answer