Bug #1252 Updated: Incorrect datetime representation in php3_mssql
| From: | sander@php.net | Date: | Sun, 16 Jun 2002 12:29:01 +0000 |
| Subject: | Bug #1252 Updated: Incorrect datetime representation in php3_mssql | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-10616@lists.php.net to get a copy of this message | ||
ID: 1252
Updated by: sander@php.net
Reported By: balchen@saint-etienne.no
-Status: Open
+Status: Bogus
Bug Type: Other
Operating System: NT 4.0 build 1381 (SP 3, multi-p
PHP Version: 3.0.6
New Comment:
Thank you for taking the time to report a problem with PHP.
Unfortunately, PHP 3 is no longer supported. Please download
the latest version of PHP 4 from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Previous Comments:
------------------------------------------------------------------------
[1999-03-21 15:45:55] balchen@saint-etienne.no
Datetime fields are represented in MS SQL as 8 byte floating point
numbers, and the return value in an SQL query is a 17 byte string, but
the module php3_mssql seems to interpret them a an 8 byte string.
When executing a command similar to this,
list(.., $date, ...) = mssql_fetch_row($result);
you get a $date that contains the first 8 bytes of the return value
instead of the actual date string. This means that (at least on my
system), $date contains "Mar 21 1", whereas the return value from MS
SQL is "Mar 21 1999 21:00".
date() totally gives up when giving it $date, and returns Jan 01 1970.
The only solution is to execute a slightly modified SQL statement,
converting the datetime field to a varchar using CONVERT, like this:
SELECT CONVERT(varchar(17), datefield) FROM table
This will return a 17 byte string that php3_mssql doesn't fuck up.
It doesn't like a system-specific problem to me, but anyway: I'm
running NT 4.0, SQL Server 6.5, PHP for Win32 3.0.6 using IIS 4.0.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=1252&edit=1