Doctrine\DBAL\Types\ConversionException with all Doctrine date fields after update to PHP 8

Viewed 19

I am using Laravel 8 with Doctrine/DBAL 2.13. After updating PHP version from 7.4 to 8.1.10, when I try to retrieve all date fields from a SQL Server database, they are being sent to Doctrine in an invalid format, causing the following errors:

All date fields are being returned as 'Jan 2 2015 12:00:00:AM' instead of '2015-01-02'.

Doctrine\DBAL\Types\ConversionException: Could not convert database value "Jan  2 2015 12:00:00:AM" to Doctrine Type datetime. 
Expected format: Y-m-d H:i:s.000 in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php:53

Changing all date fields in the database to datetime fields fixes this, but I don't want to change the datatypes.

0 Answers
Related