【发布时间】:2021-01-13 16:10:22
【问题描述】:
我在插入 update_at、created_at、deleted_at 类型为整数的表时遇到问题。但据我了解,这些列的默认类型为 datetime,当我更新注释时,出现类似 Invalid text representation: 7 ERROR: invalid input syntax for type integer: "2020-09-28 04:21:06" 的错误。因此,当我创建一个新笔记时,我添加了这个 updated_at = Carbon::now()->timestamp; 但它不起作用,我无法更改表的结构和列的类型
【问题讨论】:
-
当您尝试使用此
updated_at = Carbon::now()->timestamp;时遇到什么错误? -
请去数据库..将类型
updated_at更改为timestamp并设置默认null或current timestamp... -
为什么
updated_at设置为整数?它应该是timestamp,去 pogres admin 并检查列格式。在您的迁移中,您有$table->timestamps();或者您已修改updated_at? -
默认类型不是
datetime,默认格式是timestamp两者不同。能否分享一下迁移文件? -
请尝试一下。
date('Y-m-d h:i:s ', strtotime($date));或date('Y-m-d h:i:s');
标签: laravel postgresql eloquent