Php to read mssql time display format solution. We know that mssql does not use time as php does. the generated time format DateTime is incorrect, the following code is used to copy the code while ($ rowsqlsrv_fetch_array we know that mssql does not use time as php does. the generated time format DateTime is incorrect, as shown below:
The code is as follows: |
|
While ($ row = sqlsrv_fetch_array ($ result, SQLSRV_FETCH_ASSOC )) { Print_r ($ row ['datetime']); // This field is in the time format of mssql. } The result is DateTime Object ( [Date] => 00:00:00 [Timezone_type] => 3 [Timezone] => Asia/Chongqing ) |
Solution
Method 1: define ini_set ("mssql. datetimeconvert", 0) at the beginning of the php document );
Method 2: modify php. ini and find; mssql. datetimeconvert = On. remove the semicolon and change on to off.
Method 3: only use the convert function to convert the time field of mssql into a string.
For example, SELECT *, convert (char, datetime field, 120) as str_datetime FROM table name
This str_datetime is the string. The third parameter is 120, which is in the format yyyy-mm-dd hh: ii: ss.
The pipeline code is as follows while ($ row = sqlsrv_fetch_array...