tags:

views:

25

answers:

2

I have a date where I need to add months to, but somehow it returns the epoch date

$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)));

I have no idea what I'm doing wrong?

+1  A: 

Use this instead:

$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");
Scott
+1  A: 
$newEndDate = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
Parkyprg