今天日期+ x天[关闭]

I have following function:

$invoiceParams[2] = $invoiceDate; // dueDate 

Where $invoiceDate is todays date, $invoiceParams[2] should be today's date + 7.

You can use strtotime.

echo date('m-d-Y', strtotime("+1 week"));

Use strtotime with date

$invoiceParams[2] = date('m-d-Y',strtotime(" +7 days"));

Just ran a quick benchmark and adding a flat number of seconds is at least twice as fast compared to parsing a '+7 days' or '+1 week' string.

$invoiceDate = time(); // now
$invoiceParams[2] = $invoiceDate + 604800; // +7 days

// Test
echo date('M-d, Y', $invoiceDate); // Now: Jan-03, 2013
echo date('M-d, Y', $invoiceParams[2]); // +7 days: Jan-10, 2013