2015-12-15 54 views
-2

我有以下代碼。如何更改filemtime文件目錄刪除?

$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,我該如何去改變它?

+0

是否要檢查文件是否早於'x'分鐘? –

+0

這會太簡單回答嗎?只是一個數學問題。 – Raptor

+0

是不要刪除在一天刪除文件分鐘新變量$分鐘= 1; –

回答

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); 
} 
+0

不記得變量文件時間* 24 * 60 * 60)))確定刪除H.m * 60)))謝謝! –

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

我不知道這是你在問什麼,但它似乎是適當的。

+0

no $ days = 7;更改變量分鐘? $ minute = 1; //檢查文件是否比X天早 if(filemtime($ path。$ file)<(time() - ($ minute * 60 * 60))) {??? \ –

+0

你可以嗎請證明你的回答並提出問題作爲評論? =) – bonCodigo