小编dum*_*Die的帖子

Laravel 当前在 Carbon 迁移中的时间戳

我想将created_at显示为时间戳,如下所示:

created_at : 1625501162

这是我在迁移中的created_at列:

$table->string('created_at')->Carbon::now()->timestamp;

现在我希望在创建新记录时自动创建该字段并记录当前时间。所以当我将行更改为:

$table->string('created_at')->useCurrent(Carbon::now()->timestamp);

给我这个错误:

Method call is provided 1 parameters, but the method signature uses 0 parameters

那么我该如何解决这个问题呢?

您建议使用哪些其他方法来创建时间戳并自动存储它?

migration timestamp laravel php-carbon

1
推荐指数
1
解决办法
5406
查看次数

标签 统计

laravel ×1

migration ×1

php-carbon ×1

timestamp ×1