Search code examples
phpsql-serverdatetimelocale

Wrong datetime - PHP+ SQL Server


echo date('d/m/Y H:i:s'); 
//output: 13/12/2012 11:10:57

print_r(getDataArray($dblink, 'select current_timestamp')); 
//output: Array ( [0] => Array ( [computed] => **2012-04-12 11110:05** ) )

When I try to get a "current_timestamp" + php + sql server, I get an error, an incorrect date. Can anyone help me?

  • date convert in mssql config (php.ini) is "off"

that's a problem in locale.conf ? /etc/locale.conf ....

thanks


Solution

  • The problem can be with the format that datetime columns are returned in.

    Try this in your php.ini :

    After this line:

    ;mssql.datetimeconvert = On
    

    Add this line:

    mssql.datetimeconvert = Off