1

我正在使用 Laravel。尝试显示日期时出现以下错误:

A textual month could not be found Trailing data

格式是j M Y,日期是2014-12-13 10:00:00

我不明白错误在哪里。

有什么硬仗吗?

4

1 回答 1

2

供将来参考:将 createFromFormat 与第二个参数不是 Carbon 对象一起使用给了我同样的错误。使用Carbon::parse::而不是createFromFormat似乎可以解决问题:

public function setPublishedAtAttribute($date) {
    $this->attributes['published_at'] = Carbon::parse($date);
}
于 2016-02-11T23:31:13.393 回答