I'm trying to create a carbon date as follows to store in a timestamp column:
'from_dt' => Carbon::createFromFormat('Y-m-d', Carbon::now()->year . '-04-01'),
'to_dt' => Carbon::createFromFormat('Y-m-d', Carbon::now()->addYear() . '-03-31'),
But I'm getting an [InvalidArgumentException] Trailing data
exception.
In my model I have set the protect dates property as follows:
// ensure dates are accessed and set as a date
protected $dates = ['from_dt', 'to_dt'];
What the correct way to set a date using carbon and how can I automatically work out the to_dt one year from the from_dt - currently I'm having to hard code the day and month of the to_dt.