在现有日期添加月份?

时间:2010-09-28 12:59:11

标签: php

我有一个日期需要添加月份,但不知何故它会返回纪元日期

$duration = 28;
$row['end_date'] = '2010-09-22 0000:00:00';

$newEndDate =  date("Y-m-d", strtotime(" +".$duration." month",substr($row['end_date'],0,10)));

2 个答案:

答案 0 :(得分:3)

$newEndDate = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");

答案 1 :(得分:2)

请改用:

$date = date("Y-m-d");// current date

$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");