Home » Php » php – PDO dblib date format different than tsql

php – PDO dblib date format different than tsql

Posted by: admin July 12, 2020 Leave a comment


I’ve got a CentOS 7 machine running PHP with webtatic PHP 5.6 and the php56w-mssql package installed. My application is in the Laravel framework connecting to an MSSQL 2012 database.

I’ve modified the locales.conf file so that all it has in it is

    date format = %Y-%m-%d %I:%M:%S.000

And when running a query from within tsql I get back the properly formatted date including the zeros for milliseconds at the end. However, when running the query either in PHP interactive mode, or through artisan tinker, I get a date format without the trailing milliseconds.

I have an Ubuntu machine running the exact same configuration, and tsql, PHP, and artisan tinker all give me back the properly formatted date, it’s just this CentOS machine that’s an issue.

My freetds.conf sets tds version 7.4 for it’s global setting and has the host entry (which is what is currently configured in Laravel) that is

    host =
    port = 1433
    database = fancy
    tds version = 7.4
    client charset = UTF-8
How to&Answers: