Reputation: 17467
I inherited a Laravel project and am running into a strange issue with date formatting.
I get the following error:
InvalidArgumentException in Carbon.php line 582
Unexpected data found.
Unexpected data found.
The separation symbol could not be found
Unexpected data found
Trailing data
The stack track shows the problem has to do with a date time conversion:
at Carbon::createFromFormat('Y-m-d H:i:s.u', 'Oct 10 2017 02:31:04:493PM') in Model.php line 3003
I can see that there is a weird date format with 02:31:04:493PM
as the time. I don't know where that format is coming from and I've spent literally all day trying.
All of the date formats in the application code are of the 'Y-m-d H:i:s.u' or 'Y-m-d H:i:s' format. I don't know where this invalid one with the :
before microseconds is coming from and I can't seem to find it anywhere in the code.
I've checked in Model.php, Carbon.php, all of the app Models that inherit from Model, etc. When I run the project on localhost environment, everything loads fine, but when I try on the dev environment, this error happens.
The leads me to believe it is something environment specific, but I don't know enough about Apache/PHP/SQL Server to know where the formatting is coming from. The data in the database appears just fine as normal datetime values.
Any ideas or suggestions on where to look?
Upvotes: 0
Views: 419
Reputation: 17467
The issue was resolved by migrating our PHP server from FreeBSD to IIS.
Our environment did not have the appropriate PDO SQLSRV drivers to communicate to our SQL Server database properly and Microsoft doesn't provide pre-compiled versions for FreeBSD.
Our organization did not need to use FreeBSD and so we moved to IIS because it was easier for our new members to manage. With IIS, we were able to download the Microsoft PDO SQLSRV drivers that are compiled for IIS/Windows and this made the DB queries yield the correct date formats.
Upvotes: 0