我有以下代码。
$days = 7;
// Check if the file is older than X days old
if (filemtime($path.$file) < ( time() - ( $days * 24 * 60 * 60 ) ) )
{
// Do the deletion
unlink($path.$file);
}
我想改成$days
,$minute
怎么改?
$minute = 1440 * $days;
// there are 1440 minutes in a day
我不知道这是否是您要问的……但这似乎是合适的。
如果要检查文件是否早于x
分钟,则可能适用以下代码。
$minutes = 15;
// Check if the file is older than x minutes
if (filemtime($path.$file) < ( time() - ( $minutes * 60 ) ) ) {
// Do the deletion
unlink($path.$file);
}