I recently upgraded the current version of PHP on my server to 5.3.20. Since then, when I pull data from the MSSQL database (mssql_query), I get strangely incorrect dates.
I checked the locale settings and the default time zone is set to "Australia / Brisbane", I also checked the php.ini settings and confirmed that mssql.datetimeconvert disabled. It seems that the dates go through pre-formatted (without seconds) when the option is on, however, when the option is off, I get a date that looks like this.
mssql.datetimeconvert (off): 2013-07- 38 16:00:20
mssql.datetimeconvert (on): Feb 07 2013 21:37 PM
Is there a simple fix?
Here is the code that compares the output between mysql / mssql sources:
$rs = $db->query("select id, servertime from bobstable where id = 86427420"); $mss_set = mssql_query("select id, servertime from T_bobstable WITH (NOLOCK) where id = 86427420"); $myrow = $rs->fetch_assoc(); $msrow = mssql_fetch_array($mss_set); var_dump($myrow); echo "<br>"; var_dump($msrow);
which is displayed as follows:
array(2) { ["id"]=> string(8) "86427420" ["servertime"]=> string(19) "2013-02-08 14:00:24" } array(4) { [0]=> float(86427420) ["id"]=> float(86427420) [1]=> string(19) "2013-08-39 24:673:0" ["servertime"]=> string(19) "2013-08-39 24:673:0" }
and this is the result that I get directly from SQL Server Studio
2013-02-08 14:00:24.673
I can understand how it was formatted (since this part of the problem was given below), but I cannot understand why this is happening in this format or how to change the PHP configuration to avoid this. Before I updated PHP, it used 2013-02-08 14:00:24 . Has anyone experienced or seen this before?
source share