php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51863 PDO Informix - date format
Submitted: 2010-05-19 22:52 UTC Modified: 2010-08-20 17:38 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: corey dot barnes at verizon dot com Assigned: kalle (profile)
Status: Closed Package: PDO related
PHP Version: 5.1.6 OS: RHEL 5 - linux
Private report: No CVE-ID: None
 [2010-05-19 22:52 UTC] corey dot barnes at verizon dot com
Description:
------------
When using the PDO connection option to an Informix data base the date is returned in the format YYYY-MM-DD instead of in the format that it is stored in the database.

Test script:
---------------
try {
  $pdo=new PDO('informix:host=$host; database=$db; server=$server; protocol=onsoctcp;',"","",array(PDO::ATTR_PERSISTENT=>true));
 } catch (PDOexception $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
 }

 $sql = "SELECT dba_date,due_date FROM work_requests Where work_id='6862105'";
 $q = $pdo->prepare($sql);
 $q->execute();
 $q->setFetchMode(PDO::FETCH_BOTH);
 while($sqlr = $q->fetch()){
     print $sqlr['DBA_DATE'] ."<br>";
     print $sqlr['DUE_DATE'] ."<br>";
 }


Expected result:
----------------
mm/dd/yyyy

Actual result:
--------------
yyyy-mm-dd

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-20 14:10 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2010-05-20 14:10 UTC] mike@php.net
Hi, is this by any chance dependent on your locale, or on a date output format setting of the server?
 [2010-05-20 15:17 UTC] corey dot barnes at verizon dot com
-Status: Feedback +Status: Open -PHP Version: 5.2.13 +PHP Version: 5.1.6
 [2010-05-20 15:17 UTC] corey dot barnes at verizon dot com
This is not dependent on a server setting. I can query using IFX functions (for INFORMIX) and the date is returned in the correct format, but when I use the PDO functions it returns as yyyy-mm-dd (instead of mm/dd/yyyy).
 [2010-06-03 17:56 UTC] rgagnon24 at gmail dot com
This could be to keep the date format standard among all PDO drivers, so code does not need to be aware of the database storage types.

Also, pdo_informix is a PECL extension.  Should this be an issue for PECL?
 [2010-06-03 18:01 UTC] rgagnon24 at gmail dot com
Another thing I just thought about.  If the date format were to be changed now, it would break compatibility with existing PHP code.
 [2010-06-27 00:22 UTC] felipe@php.net
-Summary: date format +Summary: PDO Informix - date format
 [2010-08-20 17:38 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-08-20 17:38 UTC] kalle@php.net
PDO Informix is not maintained in core anymore, please report it to the IBM guys at pecl.php.net, thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC