CalcBuilder Forum

Add Number of Days and format Correctly

Usuario phil_adler 2016-02-05 17:27:59

I am trying to make a calculator that takes the date format adds 90 days to it and outputs the result in mm/dd/yy format. This is the code I have so far but I just cant get it to work:

$aDate = new DateTime($arrestDate);
$mDate = new DateInterval('P90D');
$fDate = new DateInterval('P175D');


$speedydate = date_add($adate,$mdate);
It doesnt seem to like the date_add

Please help

Thanks

Phil

Moonsoft support 2016-02-05 20:10:46

Hi,
your code seems correct, but you have passed the parameters to date_add without the uppercases inside (aDate, mDate,) this should do the work:


$speedydate = date_add($aDate,$mDate);

//and now you can print with your preferred format

$formatedspeedydate=date_format($speedydate, 'm-d-Y');


Hope this helps, regards