-2

我有以下代码。

$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怎么改?

4

2 回答 2

0
$minute = 1440 * $days;
// there are 1440 minutes in a day

我不知道这是否是您要问的……但这似乎是合适的。

于 2015-12-15T02:59:50.857 回答
0

如果要检查文件是否早于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);  
}
于 2015-12-15T03:04:15.353 回答