Change the time on a file using php touch()

Using touch() it is possible to alter the time stamp on a file by doing the following:

$time = time() – 3600; // Minus 1 hour
touch($directory.$file, $time);

This proves to be useful when a script needs to list the files in a directory displaying the date. The date may not always be the time last touched, but a time in the past.

Tags: , , ,

About Keiron

Web Developer based in the UK. Click here if you want to work with me