添加分钟到strtotime

If i have a varible

// in minutes
$min = 40;

And i want to add it to a strotime formatted time

$strtTime = $strtotime('now') + $min; 

whats the correct way to do this?

You can do this:

strtotime("+{$min} minutes");

There's not much to it:

echo strtotime("+40 minutes");

See it in action

Well, look at the documentation. It tells you how to use the function.

$future = strtotime('+40 minutes');

You can also be a little more concrete and include where to start from.

$future = strtotime('now + 40 minutes');

While the above is a lot easier you could also do it manually. It just involves some basic arithmetic:

$now     = time(); // Seconds since 1970-01-01 00:00:00
$minutes = 40;
$seconds = ($minutes * 60); // 2400 seconds
$future  = ($now + $seconds);
$min = 40;

And i want to add it to a strotime formatted time

$strtTime = strtotime("+".$min." minutes", strtotime('now'));//eg +40 minutes