Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sonicitiskg's avatar

Laravel can't update data when using SQL Server database on Ubuntu

Hi guys,

I have a problem when deploying my application on ubuntu. I develop my apps on Windows, using XAMPP + Laravel 5.5 + SQL Server. When I deploy to ubuntu server, the application cannot do the update data. The error is "Data Missing". It caused by datetime format on SQL Server using milliseconds, (yyyy-mm-dd hh:ii:ss.000), but my application not produce that format (my apps produce yyyy-mm-dd hh:ii:ss).

I have been trying to edit .../HasAttributes.php & SqlGrammar.php but nothing helps.

Is anyone happened this things?

Thanks.

0 likes
10 replies
jestins's avatar

Try to use Carbon.

or update the column structure to to accept date time

sonicitiskg's avatar

I've used Carbon. The problem just when update, on insert everything goes well. And the column on SQL Server using datetime type.

jestins's avatar

Are you using carbon's createFromFormat ?

sonicitiskg's avatar

the error point that function at Illuminate/Database/Eloquent/Concerns/HasAttributes.php

jestins's avatar
jestins
Best Answer
Level 1

It's look like carbon createFromFormat error, If your date string is "shorter" than the format that time this kind of error arise. Not related to DB

sonicitiskg's avatar

yeah, but the strangest things that it errors just for update feature, when insert everything goes well. (on Ubuntu)

When i use Mac OS or Windows, everything works fine..

mdecooman's avatar

@sonicitiskg

Can you write and run a copy of the update query manually on your Ubuntu and see what you get? That should give you some answers.

sonicitiskg's avatar

@mdeecooman : I have run my update query using sqlcmd command on my ubuntu, everything worked fine.

@jestins : I update data using Eloquent. $user = User::find(1); $user->user_firstname = 'Sitty'; $user->save();

that's my code.

sonicitiskg's avatar

Hi guys, it solved.

I just add one line at all my models.

protected $dateFormat = 'Y-m-d H:i:s';

Before I add that code, I write protected $dateFormat = 'Y-m-d H:i:s.v' on my models.

Thanks for sharing everyone..

Please or to participate in this conversation.