php - Why does laravel get an error when assigning a value to created_at or updated_time in the controller?
迷茫
迷茫 2017-05-16 13:17:08
0
3
602

HTML:

Controller:

Page error:

Then, I just need to redefine a variable, like this
Controller:

So, I don’t understand why laravel makes an error when assigning created_at or updated_time in the controller.
Help Me!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
漂亮男人

The system classifies created_atupdated_atdeleted_at字段格式化为了CarbonCarbon.

// 例子
$posts->created_at->timestamp;  // 时间戳
$posts->created_at->format('Y-m-d H:i:s');  // 返回指定格式
// Carbon支持很多操作

About CarbonCarbon的了解,可访问官网:http://carbon.nesbot.com/ (绝对推荐使用)

左手右手慢动作

Please post the complete code.

某草草

要用Carbon
$post->updated_time = Carbon::now();
$post->updated_time = Carbon::parse('2017-01-01');
$post->updated_time = Carbon::createFromTimestamp(1491747387);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template