I'm having a table where I'm storing the data in date format through datepicker. While storing the date I'm doing something like this:
$data['schedule'] = Carbon::parse($request->schedule)->toDateTimeString();
then in model I've defined like following:
protected $dates = [
'schedule', 'created_at', 'updated_at', 'deleted_at'
];
Now while retrieving the date I'm using diffForHumans()
something like this:
$event->schedule = $event->schedule->diffForHumans();
But it is throwing an error like this:
A two digit month could not be found. Data missing
I checked mySQL database for the format , I'm having dates like this:
2017-07-02 14:38:23
Edit:
Previously I was having an issue while storing the date in tables, please refer to How to format date receiving through Vuejs Datepicker in laravel for the detailed description. It throws error of:
Invalid datetime format: 1292 Incorrect datetime value: '2017-05-04T18:30:00.000Z' for column 'schedule' at row 1
So I chose to use Carbon::parse
while storing it in database.
How to resolve this, help me out.
Thanks.
Carbon::parse...
then it is not accepting values in table – Toschdd($request->schedule);
before$data['schedule']
? – Leonialeonid