Re: Unlink file older then 7 days

From: Date: Mon, 16 Jul 2007 13:38:33 +0000
Subject: Re: Unlink file older then 7 days
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-258917@lists.php.net to get a copy of this message
chris@aquanuke.com wrote: > How would I use fileatime to check if the file is older then 7 days? Erm, If the fileatime is > 7 days??? OK, not quite. This checks the file ACCESS time. This means the last time the file was read etc. Now bear in mind that access times for files is generally a very useless statistic that is very rarely used and to squeeze power out of resources most web server admins would mount their partitions with noatime option which would disable this statistic!! http://ca3.php.net/manual/en/function.filemtime.php is probably a more appropriate check - based on when the file was last modified. Col PS just in case you were literally asking how, the int that is returned from these functions are just seconds since epoch, so compare to time() and if the difference is > (7 * 24 * 60 * 60), it's older than 7 days!

« previous php.general (#258917) next »