Bug #54648 [Com]: PDO::MSSQL forces format of datetime fields
| From: | mirigoyen at icihomes dot com | Date: | Wed, 03 Jun 2015 13:23:22 +0000 |
| Subject: | Bug #54648 [Com]: PDO::MSSQL forces format of datetime fields | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193090@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54648&edit=1
ID: 54648
Comment by: mirigoyen at icihomes dot com
Reported by: mail at tomsommer dot dk
Summary: PDO::MSSQL forces format of datetime fields
Status: Assigned
Type: Bug
Package: PDO DBlib
Operating System: Linux
PHP Version: 5.3.6
Assigned To: ssufficool
Block user comment: N
Private report: N
New Comment:
I can confirm this is still an issue in PHP 5.6.5 and is causing major problems for us.
Previous Comments:
------------------------------------------------------------------------
[2013-02-12 16:45:52] d dot vergini at gameprog dot it
workaround if using freetds library
edit (or create if not exists)
/etc/freetds/locales.conf
with the following 2 rows
[default]
date format = %Y-%m-%d %H:%M:%S.%z
------------------------------------------------------------------------
[2011-08-14 02:09:29] ssufficool at gmail dot com
It seems the standard ANSI SQL date/time format should be YYYY-MM-DD HH:MM:SS.F
The PDO and MSSQL conversions drop the fraction. Unfortunately this cause major breakage if it were
"standardized" since php does not convert fractional times.
IMHO, all PDO drivers should return the date/time & interval values in YYYY-MM-DD HH:MM:SS
format.
------------------------------------------------------------------------
[2011-05-02 10:06:25] mail at tomsommer dot dk
Description:
------------
The PDO::MSSQL layer forces a format upon datetime fields, which cannot be altered. The MSSQL
extension does not.
mssql.datetimeconvert apparently has no effect on PDO.
Test script:
---------------
ini_set('mssql.datetimeconvert', 0);
$sql = mssql_query("SELECT GETDATE()");
var_dump(mssql_fetch_assoc($sql));
var_dump($mssql->query("SELECT GETDATE()")->fetch());
Expected result:
----------------
array
'computed' => string '2011-05-02 10:02:08' (length=19)
array
'computed' => string '2011-05-02 10:02:08' (length=19)
0 => string '2011-05-02 10:02:08' (length=19)
Actual result:
--------------
array
'computed' => string '2011-05-02 10:02:08' (length=19)
array
'computed' => string 'maj 02 2011 10:02:08' (length=20)
0 => string 'maj 02 2011 10:02:08' (length=20)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54648&edit=1