如何处理返回 '-0001-11-30 00:00:00' 的 MySQl 空日期

How to handle MySQl null dates returning '-0001-11-30 00:00:00'

当我的 MySQl 日期为空时,PHP returns 它们会显示为“-0001-11-30 00:00:00”。

我知道这是因为我使用的是欧洲时区,但我该如何处理呢?

我不断得到:

InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
in Carbon.php line 425
at Carbon::createFromFormat('Y-m-d H:i:s', '-0001-11-30 00:00:00') in Model.php line 2915

我该如何解决这个问题?

米克

注意:这不同于: How do you explain the result for a new \DateTime('0000-00-00 00:00:00')?

这是不同的,因为我在问我应该怎么做。

基于这个很好的答案: 在第 8 点)它说

MySQL stores "0000-00-00 00:00:00" if you set a datetime column as NULL, unless you specifically set the column to allow null when you create it.

这可能是解决方案,创建 table 具有可为空的日期时间列