How to format date receiving through Vuejs Datepicker in laravel

試著忘記壹切 提交于 2019-12-31 04:47:05

问题


I'm building an application in Vuejs with Laravel as backend. I'm using datepicker to add dates in column. I'm getting an error of

Invalid datetime format: 1292 Incorrect datetime value: '2017-05-04T18:30:00.000Z' for column 'schedule' at row 1

I'm sending the date in request:

And while doing dd in laravel I'm getting:

Can someone guide me how to achieve this.


回答1:


You could use Carbon to parse the date and format it accordingly

$mydate = '2017-05-04T18:30:00.000Z'; // $request->schedule

$parsed_date = Carbon\Carbon::parse($mydate)->toDateTimeString();



回答2:


Maybe you could change your request date format by using moment(this.schedule).format('YYYY/MM/DD HH:mm:ss'). Then in server you could parse easily with new(Carbon(request('schedule'));



来源:https://stackoverflow.com/questions/44275671/how-to-format-date-receiving-through-vuejs-datepicker-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!