Re: Unlink file older then 7 days
| From: | Stut | Date: | Mon, 16 Jul 2007 13:40:48 +0000 |
| Subject: | Re: Unlink file older then 7 days | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258918@lists.php.net to get a copy of this message | ||
Suhas Pharkute wrote:
http://us.php.net/manual/en/function.fileatime.php $filename = 'somefile.txt'; if (file_exists($filename) && fileatime($filename) < (time()-(7*24*60*60)) ) { unlink($filename); } Read docs!You too! The OP wanted a way to "check the age of all files". The fileatime function will return when the file was last accessed. Accessing a file is not usually deemed to affect its age, modifying it is. The filemtime function is what the OP wants. -Stut -- http://stut.net/ > On 7/16/07, chris@aquanuke.com <chris@aquanuke.com> wrote: >> >> How would I use fileatime to check if the file is older then 7 days? >> >> >> >> >> >> >> I have a directory with .txt and .txt.asc files. >> >> >> >> What I want to do is.. >> >> >> >> Check the age of all files ending in .txt.asc >> >> >> >> and if the file *.txt.asc is older then 7 days >> >> >> >> delete thatfile.txt.asc and also thatfile.txt >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >>