Laravel model Trailing Data when save the model

前端 未结 6 808
青春惊慌失措
青春惊慌失措 2021-01-02 02:00

I have some code like this

    $editStuState = StuAtt::where(\'studentId\' , \'=\' , $id)->first();
    $editStuState -> leave +=1;
    $editStuState -         


        
6条回答
  •  攒了一身酷
    2021-01-02 02:29

    Trailing data is a Carbon error, it's because you probably use Postgres and your date returns milliseconds.

    "created_at" => "2018-04-19 07:01:19.929554"
    

    You can add the following method to your (base) model.

    public function getDateFormat()
    {
         return 'Y-m-d H:i:s.u';
    }
    

    If you are using TIME WITH TIMEZONE in Postgres then the format should be:

    Y-m-d H:i:s.uO
    
    

提交回复
热议问题