php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54648 PDO::MSSQL forces format of datetime fields
Submitted: 2011-05-02 10:06 UTC Modified: 2014-10-25 04:46 UTC
Votes:20
Avg. Score:4.3 ± 0.7
Reproduced:19 of 19 (100.0%)
Same Version:3 (15.8%)
Same OS:17 (89.5%)
From: mail at tomsommer dot dk Assigned: ssufficool (profile)
Status: Closed Package: PDO DBlib
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
 [2011-05-02 10:06 UTC] 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)


Patches

PDO_DBLIB-force-format-of-datetime-fields (last revision 2011-11-15 13:23 UTC by steven dot lambeth at gmx dot de)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-02 10:07 UTC] tomsommer@php.net
-Summary: PDO forces format of datetime fields +Summary: PDO::MSSQL forces format of datetime fields
 [2011-08-14 02:09 UTC] 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.
 [2013-02-12 16:45 UTC] 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
 [2014-01-01 12:44 UTC] felipe@php.net
-Package: PDO related +Package: PDO DBlib
 [2014-10-25 04:46 UTC] ssufficool@php.net
-Assigned To: +Assigned To: ssufficool
 [2015-06-03 13:23 UTC] mirigoyen at icihomes dot com
I can confirm this is still an issue in PHP 5.6.5 and is causing major problems for us.
 [2016-02-29 16:08 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=53c036b30bdabedf841fb8716a7cd722bbab09a3
Log: Fixed #54648 PDO::MSSQL forces format of datetime fields
 [2016-02-29 16:08 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2023-05-16 05:40 UTC] giw42161 at uooos dot com
(https://centurylawfirm.in/)gist.github.com


(https://www.centurylawfirm.in/blog/combating-mob-lynching-analysing-legal-frameworks-and-preventive-measures-for-a-safer-society/)gist.github.com
(https://www.centurylawfirm.in/blog/best-advocate-in-delhi-qualities-to-look-for-choosing-the-correct-one-for-you/)gist.github.com
(https://www.centurylawfirm.in/blog/understanding-the-process-of-making-a-police-complaint-in-india-a-guide-for-commoners/)gist.github.com
(https://www.centurylawfirm.in/blog/section-498a-of-the-indian-penal-code/)gist.github.com
(https://www.centurylawfirm.in/blog/when-do-you-need-to-hire-the-best-advocate-in-delhi/)gist.github.com

(https://www.centurylawfirm.in/blog/things-to-consider-before-choosing-a-criminal-lawyer-in-delhi/)gist.github.com
(https://www.centurylawfirm.in/blog/criminal-lawyer-in-delhi/)gist.github.com


(https://www.centurylawfirm.in/blog/lawyer-for-writ-petition/)gist.github.com
(https://www.centurylawfirm.in/blog/best-law-firm-in-delhi/)gist.github.com
(https://www.centurylawfirm.in/blog/best-law-firm-in-delhi/)gist.github.com
(https://www.centurylawfirm.in/blog/muslim-divorce-lawyer/)gist.github.com
(https://centurylawfirm.in/blog/how-to-take-mutual-divorce/)gist.github.com

(https://www.centurylawfirm.in/blog/things-to-consider-before-choosing-a-criminal-lawyer-in-delhi/)gist.github.com
(https://www.centurylawfirm.in/blog/criminal-lawyer-in-delhi/)gist.github.com


(https://centurylawfirm.in/blog/divorce-lawyer-in-delhi-2/)gist.github.com
(https://centurylawfirm.in/blog/debt-recovery-tribunal-drt/)gist.github.com
(https://centurylawfirm.in/blog/get-bail-in-india/)gist.github.com
(https://centurylawfirm.in/blog/best-lawyer-for-criminal-case/)gist.github.com
(https://centurylawfirm.in/blog/high-court-cases/)gist.github.com
(https://centurylawfirm.in/blog/cheque-bounce-case/)gist.github.com
(https://centurylawfirm.in/blog/how-to-take-mutual-divorce/)gist.github.com



(https://www.centurylawfirm.in/blog/payment-recovery-cases/)gist.github.com (https://www.centurylawfirm.in/blog/mutation/)gist.github.com (https://www.centurylawfirm.in/blog/loan-matters/)gist.github.com (https://www.centurylawfirm.in/blog/corporate-law/)gist.github.com (https://www.centurylawfirm.in/blog/law-firm/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-lawyer-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/frequently-asked-questions-in-cheque-bounce-cases/)gist.github.com (https://www.centurylawfirm.in/blog/criminal-lawyer-in-delhi-2/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-lawyer-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/regular-bail-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/best-law-firm-in-delhi-2/)gist.github.com (https://www.centurylawfirm.in/blog/law-firm-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/civil-lawyer-in-new-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/top-10-lawyers-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/criminal-lawyer-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/top-10-lawyers-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/criminal-lawyer/)gist.github.com (https://www.centurylawfirm.in/blog/civil-case-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/matrimonial-case-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/civil-case-in-delhi-2/)gist.github.com (https://www.centurylawfirm.in/blog/lawyer-for-drt-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/court-marriage/)gist.github.com (https://www.centurylawfirm.in/blog/criminal-lawyer-in-rohini-2/)gist.github.com (https://www.centurylawfirm.in/blog/nri-lawyer-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/property-lawyer-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/advocate-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/bail-matter-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/bail-in-rape-case-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/bail-matters/)gist.github.com (https://www.centurylawfirm.in/blog/anticipatory-bail/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-lawyer-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-lawyer-in-rohini-2/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-case-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-case/)gist.github.com (https://www.centurylawfirm.in/blog/divorce-cases/)gist.github.com
(https://www.centurylawfirm.in/blog/happy-dhanteras-2021/)gist.github.com (https://www.centurylawfirm.in/blog/happy-diwali-2021/)gist.github.com (https://www.centurylawfirm.in/blog/happy-new-year-2022/)gist.github.com (https://www.centurylawfirm.in/blog/happy-republic-day-2022/)gist.github.com (https://www.centurylawfirm.in/blog/mutual-divorce/)gist.github.com (https://www.centurylawfirm.in/blog/best-lawyer-for-property-dispute-cases/)gist.github.com (https://www.centurylawfirm.in/blog/happy-holi-2022/)gist.github.com (https://www.centurylawfirm.in/blog/lawyer-for-fir-quashing-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/bail-in-criminal-case-in-delhi-2/)gist.github.com (https://www.centurylawfirm.in/blog/matrimonial-dispute-lawyer-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/lawyer-for-cheque-bounce-case-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/best-lawyer-for-criminal-case/)gist.github.com (https://www.centurylawfirm.in/blog/latest-legal-awareness-videos-may-2022/)gist.github.com (https://www.centurylawfirm.in/blog/advocate-in-rohini-courts-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/advocate-in-karkardooma-court/)gist.github.com (https://www.centurylawfirm.in/blog/advocate-for-accident-claim-cases/)gist.github.com (https://www.centurylawfirm.in/blog/marriage-under-special-marriage-act-can-be-registered-through-video-conferencing-supreme-court-of-india/)gist.github.com (https://www.centurylawfirm.in/blog/maintenance-welfare-of-parents-senior-citizens/)gist.github.com (https://www.centurylawfirm.in/blog/arbitration-latest-supreme-court-judgement/)gist.github.com (https://www.centurylawfirm.in/blog/matrimonial-dispute-lawyer-in-rohini/)gist.github.com (https://www.centurylawfirm.in/blog/bail-in-376-rape-case-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/lawyer-for-civil-case-in-delhi-2/)gist.github.com (https://www.centurylawfirm.in/blog/lawyer-for-civil-case-in-tis-hazari-court/)gist.github.com (https://www.centurylawfirm.in/blog/lease-hold-to-free-hold-conversion/)gist.github.com (https://www.centurylawfirm.in/blog/latest-legal-awareness-videos-december-2021/)gist.github.com (https://www.centurylawfirm.in/blog/latest-legal-awareness-videos-january-2022/)gist.github.com (https://www.centurylawfirm.in/blog/cheque-bounce-case-latest-sc-guidelines-2021/)gist.github.com (https://www.centurylawfirm.in/blog/bail-in-criminal-case-in-delhi/)gist.github.com (https://www.centurylawfirm.in/blog/latest-legal-awareness-videos-february-2022/)gist.github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC