Thanks Martin, it's definitely what is coming back from the database (I
use Zend Studio to debug and can watch it happening).
Actually it appears there is a default setting for the mssql extension
that I was unaware of. I have to set the following in my php.ini to
force the extension to keep its mitts off my datetime!
mssql.datetimeconvert = off
...and now I get back the correct datetime as originally stored in the
Norland, Martin wrote:
How are you printing/extracting this information? I find it very
unlikely that it's returning that string - it would eliminate any
localization opportunities as well as time conversion / math operations.
Use print_r() to print the contents returned from SQL Server directly,
if you're using date functions , you're already specifying the format
you want and you just need to add the seconds.
If it really is returning that, then check that you're not using some
helper classes or functions either with the returned value or to build
the SQL query, it's possible there's some sort of "human readable" MSSQL
option being passed in the SQL.
- Martin Norland, Sys Admin / Database / Web Developer, International
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
From: Alex Gemmell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 06, 2005 11:15 AM
Subject: [PHP-DB] Does PHP strip out the seconds from a SQL Server
datetime field?. .
I'm using PHP 4.4.1 and pulling out records from a SQL Server database.
I use the mssql extension in PHP to connect to SQL Server. My website
works fine for the most part but I have noticed something odd with the
dates returned from SQL Server.
In my SQL Server table I have many datetime fields. For example I can
clearly see (using Enterprise Manager) the field "fldDateCreated"
contains the datetime "06/12/2005 16:20:35" but oddly when I extract
this field into a PHP variable the variable contains this: "Dec 6 2005
Annoyingly I lose the seconds and I need the entire date and time. Can
anyone explain why the datetime is getting "converted"? What is doing
it (presumably PHP) and how can I get it to stop?
FYI: I use "mssql_pconnect()" to connect to the SQL Server database and
"mssql_fetch_assoc()" to extract each row.
Thanks for any help offered!
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php