|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1252 Incorrect datetime representation in php3_mssql
Submitted: 1999-03-21 15:45 UTC Modified: 2002-06-16 08:29 UTC
From: balchen at saint-etienne dot no Assigned:
Status: Not a bug Package: Other
PHP Version: 3.0.6 OS: NT 4.0 build 1381 (SP 3, multi-p
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: balchen at saint-etienne dot no
New email:
PHP Version: OS:


 [1999-03-21 15:45 UTC] balchen at saint-etienne dot 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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 08:29 UTC]
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

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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 20:01:29 2024 UTC