Carbon.php第425行中的Laravel InvalidArgumentException:使用SQL数据库跟踪数据 [英] Laravel InvalidArgumentException in Carbon.php line 425: Trailing data with SQL database

查看:105
本文介绍了Carbon.php第425行中的Laravel InvalidArgumentException:使用SQL数据库跟踪数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的laravel 5.2应用程序从MYSQL更新到SQL数据库,在遇到此异常之后,我一直遇到碳日期格式问题.

I am updating my laravel 5.2 application from MYSQL to SQL database, I have been facing carbon dateformat issues following this exception.

InvalidArgumentException in Carbon.php line 425:
Trailing data

和堆栈跟踪看起来像这样

and stack trace looks like this,

in Carbon.php line 425
at Carbon::createFromFormat('Y-m-d H:i:s.000', '2016-11-20 13:56:28.0000000') in Model.php line 2990
at Model->asDateTime('2016-11-20 13:56:28.0000000') in Model.php line 2668
at Model->getAttributeValue('created_at') in Model.php line 2634

当我出于调试目的删除carbon.php文件中的尾随四个零时,问题得到解决.

When I remove the trailing four zeros in carbon.php file for debug purpose, problem gets resolved.

关于如何在模型端解决此问题或任何其他解决方案的任何想法?

Any idea of how to resolve this on model end or any other solution??

推荐答案

如果以微秒为单位,请尝试将其放入模型文件中.

If it's a microseconds, try putting this in your Model file.

protected $dateFormat = 'Y-m-d H:i:s.u';

似乎是datetime2格式,请尝试使用

Seems like it's a datetime2 format, try using

protected $dateFormat = 'Y-m-d H:i:s+';

这篇关于Carbon.php第425行中的Laravel InvalidArgumentException:使用SQL数据库跟踪数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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