gpt4 book ai didi

php - Laravel - 时间戳字段被读取为字符串

转载 作者:行者123 更新时间:2023-12-05 08:32:04 25 4
gpt4 key购买 nike

我的数据库中有一个自定义时间戳字段,delivery_date

$table->timestamp('delivery_date')->nullable();

每当我尝试使用这个字段时,它都会将它作为一个字符串引入...

"2018-12-17 00:00:00"

但如果我将相同的代码与 created_at 时间戳一起使用,例如,它会将其作为时间戳引入。

日期:2018-12-09 00:00:00.0 America/New_York (-05:00)

我尝试将迁移中的字段更改为 datetimedate,结果相同。

我还尝试通过...转换结果

strtotime($order->delivery_date)

但出于某种原因,它会将其转换为整数。

最佳答案

为了获得 delivery_date 作为 created_at 你必须将 delivery_date 添加到你的模型作为 protected $dates = ['delivery_date'];

关于php - Laravel - 时间戳字段被读取为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53798616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com