如何在laravel中通过Vuejs Datepicker格式化接收日期 [英] How to format date receiving through Vuejs Datepicker in laravel

查看:34
本文介绍了如何在laravel中通过Vuejs Datepicker格式化接收日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Laravel 作为后端在 Vuejs 中构建一个应用程序.我正在使用 datepicker 在列中添加日期.我收到错误

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

无效的日期时间格式:1292 不正确的日期时间值:'2017-05-04T18:30:00.000Z' 列'schedule' 在第 1 行

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:

在 laravel 中执行 dd 时,我得到了:

And while doing dd in laravel I'm getting:

有人可以指导我如何实现这一目标.

Can someone guide me how to achieve this.

推荐答案

你可以使用 Carbon 解析日期并相应地格式化

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

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

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

这篇关于如何在laravel中通过Vuejs Datepicker格式化接收日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆