Change modification date of files with PHP touch

Making 3 days older files

<?php
$directory = getcwd();
$handler = opendir($directory);
while ($file = readdir($handler)) {
       if ($file != "." && $file != "..") {
       echo $file. "n";
             if($file != 'olderfiles.php'){
             touch( $directory."/".$file, strtotime('-72 hours'));
             }   
        }
}
closedir($handler);
?>

Deleting 24 hours older files with PHP


<?php
$dir = $RESOURCEDIR."aktualis_ajanlatok/temp/";
$interval = strtotime('-24 hours');
foreach (glob($dir."*") as $file){
    if (filemtime($file) <= $interval ) unlink($file);
}

?>

Blogbook : PHP | Javascript | Laravel | Corcel | CodeIgniter | VueJs | ReactJs | WordPress