添加五分钟到filemtime函数(PHP)!

i have the flowing code

$LastModified = filemtime($somefile) ;

i want to add ten minute to last modified time and compare with current time then if $LastModified+ 10 minute is equal to current time delete the file . how can i do that ?! i'm little confusing with unix time stamp .

Since the UNIX timestamp is expressed in "seconds since 1970", you just add five minutes in seconds:

$LastModPlusFiveMinutes = $lastModified + (60 * 5);

Or, maybe more readable:

$LastModPlusFiveMinutes = strtotime("+5 minutes", $lastModified);

The unix timestamp is the number of seconds that have passed since Jan 1st, 1970.

Therefore to add 10 minutes you need to add 600 (seconds). To get the current time call time().

e.g.

$LastModified = filemtime($somefile);

if ($LastModified+600 <= time())
{
    // delete the file
}

(Note that you said "if $LastModified+ 10 minute is equal to current time delete the file" - I presume you actually meant equal to or less than, otherwise replace <= with == above).

$LastModified = filemtime($somefile);
$now = time();
if(strtotime($LastModified.'+10 minutes') >= $now){
    // delete the file.
}

That should do it.

You wrote 5 minutes in the topic and 10 minutes in the context. Anyway here is the code

$diff =  time() - $LastModified ;
if( $diff >= 10 * 60 ){  // don't use ==, you may not find the right second..
    //action
}