我正在开发 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/