在数据表中 ,如果内容为主的信息,我们可能会有一个创建和更新时间
,这个功能Tp5中已经为我们设计好了,只要在database.php中配置就可以了
只需要在表字段中添加
create_time
update_time
即可自动为我们添加时间。
database.php
我们看一下配置
// 自动写入时间戳字段
'auto_timestamp' => true,
// 时间字段取出后的默认时间格式
'datetime_format' => 'Y-m-d H:i:s',
auto_timestamp:是否启用自动时间戳,我们当然选true
datetime_format:取出后的时间格式,这里是年月日时分秒
非常的方便
网友评论