Source: ranwar.medium.com

Laravel, SQL Server, Dates and Time

Category: Laravel, PHP

We think you might be interested in this job:

I’ve recently had issues with date formats when using LaravelValet with Microsoft SQL Server on an M1 MacBook Air. Somehow the default php databa se driver used by Valet for SQL Server, pdo_dblib, mangled the date into this format so that when Carbon attempted to parse() it it ended up with the error above. I then found out that pdo_dblib had settings in: which looked like: By changing to and restarting php: The date format became: which Carbon had no trouble parse()-ing. I’ve had success before using a newer driver called pdo_sqlsrv (no configuration changes needed) instead of pdo_dblib but unfortunately I couldn’t properly add it to php to run for the M1/ARM MacBook Air and ended up with this error: so I had no choice but to use pdo_dblib. Furthermore, had I’ve been successful in adding pdo_sqlsrv to php such as in cases with Intel-based Macs, if pdo_dblib still existed as a module in php Laravel 5.6 would still prioritize it over pdo_sqlsrv as shown in src/Illuminate/Database/Connectors/SqlServerConnector.php line 41: so you’d have to either get rid of pdo_dblib which is not so easy in Valet or modify SqlServerConnector.php which is not really advisable because it’s not picked up by version control.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Community Partners