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
Post a Comment