php.net |  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
 [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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 08:29 UTC] sander@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC