我应该为 Laravel Eloquent 2 中的 created_at 和 modified_at 使用什么类型的列?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12296087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:48:23  来源:igfitidea点击:

What type of column should I use for created_at and modified_at in Laravel Eloquent 2?

mysqldatetimeintlaraveleloquent

提问by brennanag

Should I use DATETEIME? or INT?

我应该使用 DATETEIME 吗?还是INT?

Thanks!

谢谢!

EDIT: I'm specifically addressing the

编辑:我专门针对

public static $timestamps = true;

flag set in Eloquent models.

在 Eloquent 模型中设置的标志。

采纳答案by Jürgen Paul

Laravel only supports datetimefor their timestamps.

Laravel 只支持datetime他们的时间戳。

https://github.com/laravel/laravel/pull/769

https://github.com/laravel/laravel/pull/769

回答by FireSBurnsmuP

Just as an update: Mich's answeris still valid for Laravel 3 and below,

作为更新:Mich 的回答对 Laravel 3 及以下版本仍然有效,

but as of Laravel 4, it switched to supporting timestampcolumns for created_atand updated_at.

但是从 Laravel 4 开始,它切换到timestampcreated_at和 的支撑柱updated_at

Here's a related issue on GitHub

这是 GitHub 上的一个相关问题

回答by Stanislav

Laravel 5 defaults is TIMESTAMP

Laravel 5 默认是 TIMESTAMP