Search code examples
phpfreetds

FreeTDS strange date time format


After moving application to new server with updated software (moved from php 5.2.17 -> 5.3.15, FreeTDS 0.64 -> 0.82)

SELECT GETDATE()

and any other datetime function / column produces something similar to:

2012-06-219 51:527:
// proper time: 2012-08-06 09:33:02

I know I can use convert in select, but there are many stored procedures in DB that I can not change.

I tried to change /etc/locales.conf and setting date format = %Y-%m-%d %H:%M:%S, and using ini_set('mssql.datetimeconvert',1); but freetds seems to ignore it and returns Aug 06 2012 09:33AM

Is there a way to retrieve datetime columns in standard format, without modifying every query?


Solution

  • I solved this issue in a kind of brute force way - changed date format in all locales in /etc/locales.conf, I don't know which one worked, but I'm pretty sure that none of them was used as system locale.

    Anyway, using datetimeconvert is not advised, and turned off in some db abstract layer libraries (adodb in this case) so I'm still interested if there is any way to make it display proper date time