How can I store calculated time into database using time data type?
01:22 26 Feb 2019

I am trying to store calculated time into database using mysqli data type time. Calculated means I am trying to store play time or the time user spent to play game. So I have column spent_time which data type is time and I set default value 00:00:00.

When I try to store 5 minutes and 30 seconds 00:05:30 the query returns following error

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect time value: '' for column 'time_spent' at row 1

And following is the script which is inserting record using query

 $Log   = new Log;
 $Log->user_id       = request()->user()->id;
 $Log->time_spent    = $time;
 $Log->save();

Can someone kindly guide me how can I fix this error, I would appreciate.

php mysql laravel time