【发布时间】:2018-06-11 00:56:27
【问题描述】:
假设我们有一个来自 angularJs 客户端应用程序的2015-02-05T14:50:55+01:00 格式化日期时间。
现在我想将它作为DATETIME MySQL 保存在一个表中。
我知道这是iso 8601 格式化的日期时间。因此,我在模型中添加了以下代码:
protected $dateFormat = 'DATE_ISO8601';
但是当我想用这个新字段更新我的模型时,我收到了这个错误:
A textual day could not be found
Meridian can only come after an hour has been found
The format separator does not match
The format separator does not match
The format separator does not match
The timezone could not be found in the database
Data missing {"userId":1,"email":"ahmadbadpey@gmail.com","exception":"[object] (InvalidArgumentException(code: 0): A textual day could not be found
Meridian can only come after an hour has been found
The format separator does not match
The format separator does not match
The format separator does not match
The timezone could not be found in the database
Data missing at D:\\wamp\\www\\zarsystem\\vendor\
esbot\\carbon\\src\\Carbon\\Carbon.php:582)
[stacktrace]
#0 D:\\wamp\\www\\zarsystem\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasAttributes.php(715): Carbon\\Carbon::createFromFormat('DATE_ISO8601', '2015-02-05T14:5...')
我尝试了一些其他的预定义常量,例如 DATE_ATOM,DATE_W3C ,...但得到了同样的错误。
我很困惑,我不知道该怎么办?
【问题讨论】:
-
您的时间戳不是有效的 MySQL
datetime(see here)。
标签: php mysql angularjs laravel laravel-5.5