php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12655 date-format problem
Submitted: 2001-08-08 12:02 UTC Modified: 2002-04-22 17:44 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: thomas dot winkler at jawa dot at Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.6 OS: Win2k
Private report: No CVE-ID: None
 [2001-08-08 12:02 UTC] thomas dot winkler at jawa dot at
webserver: IIS5 (Win2k) 
php-version: php4.0.6 (CGI)
db-server: MS SQL Server 2000

I've run into problems when fetching fields of type datetime from the database.
When using the MS SQL Query Analyzer I get the dates formated like this out of the database:
2001-06-08 08:14:40.000
When using php to send my queries (mssql_query) to the database I get the dates formated like this: 08 06 2001 8:14

In my application I'd need the same format as i get it in the Query-Analyzer.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-16 14:06 UTC] steved at mad dot scientist dot com
Same problem.  I need access to at least the Seconds fields as we are processing telephone billing records.  Hard to bill to the seconds when you can only query minutes.  Will probably have to go back to ODBC db driver, or look at making a custom patch in my PHP_MSSQL.dll.
Steve Dillon
 [2002-04-22 15:02 UTC] steved at mad dot scientist dot com
I created a patch and submitted to php-dev group.  Didn't get much reponse so I started looking at CVS and found that a change was checked in 6 months ago for this problem, but wasn't put in to the 4.1.0 to 4.1.2 code bases.   The fix should be in 4.2.
Steve Dillon
 [2002-04-22 17:44 UTC] sniper@php.net
Reopen if you have the same problem with 4.2.0 (released today)

 [2002-04-23 14:12 UTC] mbretter at inode dot at
I wrote a patch wich has been commitef by fmk, it is php4.2

one of the latest version of php_mssql.c php_mssql.h have a patch for
this problem, because the function dbconvert() of the MSSQL-Client-Api
wich is used for converting the datetime-values does wired things.

There is a new option in the php.ini called mssql.datetimeconvert if set
to Off then the datetime values are returned in the format YYYY-MM-DD
HH:MM:SS.

This patch is also in php4.2
 [2002-12-08 16:52 UTC] xoror at infuse dot org
i'm using php 4.2.3 and i'm still having this problem ;(
where can i get php 4.2.0 so i can test if that version works ?
 [2002-12-08 17:06 UTC] xoror at infuse dot org
i've found the problem. The fix only fixed the problem for the normal datetime columntype. You'll need to do the same trick for smalldatetime columntype.

It's very easy to reproduce. 
1. create a table with 2 columns. set the first column to be datetime, and the second to be smalldatetime. 
2. set the mssql.datetimeconvert to 0. 
3. Insert a value. 
4. do a select * from the table

you'll notice that column1 has different formatting then colum2.

i've tested this with php 4.2.3 and php 4.3.0-RC2. both have the 'bug'.
 [2002-12-10 05:51 UTC] f dot vulto at re-base dot com
Reproduced with version 4CVS-2002-12-10 (dev).  Took
liberty to report this as a new bug, as this one (12655)looks closed:

   http://bugs.php.net/20920
   mssql.datetimeconvert=0 doesn't work for smalldatetime

See also:

   http://bugs.php.net/20911
   Trailing null character after mssql datetime field
 [2003-01-11 12:33 UTC] uni at natune dot net
My problem even goes further:

Regardless whether I use a smalldatetime column or a datetime column, the option "mssql.datetimeconvert = Off" doesn't work correctly.
As a matter of fact, first it worked. But when I refresh my page, the output of the datetime is as if datetimeconvert were set to "On".
Now, after some "refreshing" it keeps showing me the converted datetime (so for the moment being, the setting seems to be ON, although I turned it off hours ago and even restarted the Server).

My Configuration: PHP 4.2.3, Win XP Prof. SP1, MS SQL Server 2000, Apache 2.0.43
 [2003-01-11 14:49 UTC] uni at natune dot net
I figured out Smarty interferes with the option of setting mssql.datetimeconvert to "off".
If I use a Smarty instance in my test file, datetimeconvert cycles between on an off...and after some refreshes of the page it's eventually on.
Perhaps Smarty changes the locale settings...I don't know...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC