php - date_add() expects parameter 1 to be DateTime, string given -


i trying fetch current date , add 7 calculate date of weekly installments project. while doing encountered problem:-

date_add() expects parameter 1 datetime, string given

the line causing me error

$loan->nextpremiumdate=date_add(date("y-m-d h:i:sa"),date_interval_create_from_date_string("1 days")); 

i using laravel framework. , nextpremiumdate column in loan table.

in model table declare want "nextpremiumdate" managed date:

public class loan extends model {        protected $dates = [ "nextpremiumdate" ]; } 

then laravel return field carbon date , can do:

$loan->nextpremiumdate = $loan->nextpremiumdate->adddays(7); 

you can refer laravel docs or carbon docs more details.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -