-6

我有以下功能:

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

今天的日期在哪里$invoiceDate$invoiceParams[2]应该是今天的日期+7。

4

3 回答 3

2

Use strtotime with date

$invoiceParams[2] = date('m-d-Y',strtotime(" +7 days"));
于 2013-01-03T15:02:01.773 回答
1

You can use strtotime.

echo date('m-d-Y', strtotime("+1 week"));
于 2013-01-03T15:01:41.307 回答
0

'+7 days'只需运行一个快速基准测试并添加一个固定的秒数,与解析 a或'+1 week'字符串相比,速度至少快两倍。

$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
于 2013-01-03T15:16:11.987 回答