search

Home  >  Q&A  >  body text

php - Why does laravel get an error when assigning a value to created_at or updated_time in the controller?

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!

迷茫迷茫2784 days ago605

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 13:19:08

    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/ (绝对推荐使用)

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:19:08

    Please post the complete code.

    reply
    0
  • 某草草

    某草草2017-05-16 13:19:08

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

    reply
    0
  • Cancelreply