CalcBuilder Forum

Add Number of Days and format Correctly

User 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

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!