I have a table where I store data in date format via datepicker. When saving the date, I do something like this:
$data['schedule'] = Carbon::parse($request->schedule)->toDateTimeString();
then in the model that I defined as follows:
protected $dates = [ 'schedule', 'created_at', 'updated_at', 'deleted_at' ];
Now, getting the date, I'm using diffForHumans() something like this:
$event->schedule = $event->schedule->diffForHumans();
But he gives the following error:
Could not find a two-digit month. Missing data
I checked the mySQL database for the format, I have dates like this:
2017-07-02 14:38:23
Edit:
I used to have a problem while storing dates in tables, see How to format date retrieval via Vuejs Datepicker in laravel for a detailed description. It gives an error:
Invalid date and time format: 1292 Invalid date and time value: '2017-05-04T18: 30: 00.000Z' for the column schedule in row 1
So I decided to use Carbon::parse , storing it in the database.
How to solve this problem, help me.
Thanks.