Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0b4

Bug #11849 mssql.datetimeconvert force set to 0 - generate wrong dates
Submitted: 2007-08-16 08:27 UTC
From: smh Assigned: davidc
Status: Closed Package: MDB2_Driver_mssql (version 1.2.1)
PHP Version: 5.2.1 OS: Linux
Roadmaps: (Not assigned)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 37 - 6 = ?

 [2007-08-16 08:27 UTC] smh (Søren Møller Hansen)
Description: ------------ Probably due to a PHP bug, it seems that when mssql.datetimeconvert is set to 0. Dates from a MSSQL is converted from 16-08-2007 to 16-07-2007. I assume that PHP takes the last to digits as month - this might be caused by the MSSQL servers timeformat (it's a danish MSSQL server, probably with danish date format). It would be preferrable if the MSSQL connect method didn't automatically set mssql.datetimeconvert to 0 or at least if the option could be given through the DSN string to avoid this behavior. Test script: --------------- <?php $dsn = 'mssql://user:pass@host:1433/db' $options = array( 'debug' => 2, 'portability' => MDB2_PORTABILITY_ALL, ); $conn =& MDB2::connect($dsn, $options); $res = $conn->query("select date_field from date_table"); $row = $res->fetchRow(); echo $row["date_field"]; ?> Expected result: ---------------- I expected the script to output 2007-08-16 Actual result: -------------- The script output 2007-07-16


 [2007-08-16 12:27 UTC] davidc (David Coallier)
I'll have a look at this, adding an option could be possible I think.
 [2009-09-29 22:29 UTC] koto (Krzysztof Kotowicz)
I had the same problem with MSSQL Driver v1.2.1 and newest (as of today) FreeTDS. Recompiling PHP helped - more info at
 [2009-10-15 20:04 UTC] davidc (David Coallier)
I just noticed from the code (Driver/mssql.php) these three lines: if ((bool)ini_get('mssql.datetimeconvert')) { @ini_set('mssql.datetimeconvert', '0'); } This seems quite bogus to me but I'm investigating to see if there's a reason for that before I do anything.
 [2009-10-15 20:24 UTC] davidc (David Coallier)
-Status: Assigned +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Ok here's what I did, I added the ability to have a new option in your factory. So when you are invoking MDB2:factory you can pass $options as the second argument. In this case make sure to have the key / value pair 'datetimeconvert' => 1 or 'datetimeconvert' => true This has to be documented but the bug itself is resolved for now.