The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong??
#DELETE FILES OLDER THAN A WEEK
$handle=opendir('./backups');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
ECHO "$file<br>"; // FILE NAME PRINTS FINE
$filetime=filemtime($file);
ECHO "$filetime<br>"; // PRINTS NOTHING. WHAT IS WRONG??
$latesttime=time();
$dtime=$latesttime-$filetime;
if(is_dir($file)!=true){
if($dtime>=0){ // 604800 WILL DELETE ONE WEEK OF FILES
unlink($file);
}
}
}
}
closedir($handle);