For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > December 2005 > RE: [PHP-DB] Does PHP strip out the seconds from a SQL Server datetime field?. .









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-DB] Does PHP strip out the seconds from a SQL Server datetime field?. .
Norland, Martin

2005-12-06, 6:57 pm

=20
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.

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-----Original Message-----
From: Alex Gemmell [mailto:agemmell@gmail.com]=20
Sent: Tuesday, December 06, 2005 11:15 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Does PHP strip out the seconds from a SQL Server
datetime field?. .

Hello!

I'm using PHP 4.4.1 and pulling out records from a SQL Server database.=20
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=20
dates returned from SQL Server.

In my SQL Server table I have many datetime fields. For example I can=20
clearly see (using Enterprise Manager) the field "fldDateCreated"=20
contains the datetime "06/12/2005 16:20:35" but oddly when I extract=20
this field into a PHP variable the variable contains this: "Dec 6 2005=20
4:20PM".

Annoyingly I lose the seconds and I need the entire date and time. Can=20
anyone explain why the datetime is getting "converted"? What is doing=20
it (presumably PHP) and how can I get it to stop?

FYI: I use "mssql_pconnect()" to connect to the SQL Server database and=20
"mssql_fetch_assoc()" to extract each row.

Thanks for any help offered!

Alex

--=20
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com