CODE CODIFY.CLUB

Change modified time of file using PHP Touch()

<?php

$file = ‘touch.php’;

// One you use filemtime it stores, You will need to clear cache before using it again.
echo ‘<br/>’;
echo “$file was last modified: ” . date (“F d Y H:i:s.”, filemtime($file));

clearstatcache();
 
// This is the touch time, we’ll set it to one hour in the past.
$time = time() – ( 3600 * 24 ); // 1 day before

// Touch the file
if (!touch($file, $time)) {
    echo ‘Whoops, something went wrong…’;
} else {
    echo “<br/> $file was last modified: ” . date (“F d Y H:i:s.”, filemtime($file));
}

?>

V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed