gpt4 book ai didi

php - Laravel - 更改 created_at 以使用 unix 时间戳

转载 作者:可可西里 更新时间:2023-11-01 13:54:00 26 4
gpt4 key购买 nike

我正在开发 Laravel 4 应用程序,我想为 created_at 和 updated_at 字段保存 unix 时间戳,而不是默认时间戳值。

关于我如何实现这一点有什么建议吗?

问候,

最佳答案

你可以只获取时间戳属性,如:

$timestamp = $model->created_at->timestamp;

或者,您可以覆盖 getDateFormat() ,并创建必填字段的迁移,如:

$table->integer('created_at');
$table->integer('updated_at');

关于php - Laravel - 更改 created_at 以使用 unix 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26602720/

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