Hi!
I'm currently working on a upgrade of a large PHP application from a
Slackware Apache 1.x environment with PHP 5.0.4 to a Ubuntu Apache 2.2.4
environment using PHP 5.2.3 (Ubuntu package). Since our databases are
running on a MS-SQL 2000 server we're also using the FreeTDS library
with the mssql-support in PHP.
One thing I noticed is that the default datetime-format returned by
MS-SQL/FreeTDS/whatever component invoked here has changed from the old
environment to the new one. An behavior that seems quite odd...
This is how a datetime column in MS-SQL was returned on our old environment:
Aug 27 2007 12:00AM
And this is how I now get the same column from the same server:
Aug 27 2007 12:00:00:000AM
As you can see the milliseconds have been added, but should not
milliseconds be separeted by a dot? Like 12:00:00.000? At least, that's
the format strtotime() understands, if you remove the AM...
As you all guess by now my application relies on passing the
smalldatetime columns returned directly from MS-SQL to the strtotime()
function for getting the UNIX-time. I played around a bit to test what
formats strtotime() understands:
echo "TIME: ".strtotime("Aug 27 2007 12:00:00:000AM");
echo "TIME: ".strtotime("Aug 27 2007 12:00:00.000AM");
echo "TIME: ".strtotime("Aug 27 2007 12:00:00:000");
echo "TIME: ".strtotime("Aug 27 2007 12:00:00.000");
echo "TIME: ".strtotime("Aug 27 2007 12:00:00AM");
echo "TIME: ".strtotime("Aug 27 2007");
echo "TIME: ".strtotime("Aug 27 2007 12:00AM");
Output:
TIME:
TIME:
TIME:
TIME: 1188205200
TIME: 1188162000
TIME: 1188162000
TIME: 1188162000
In the documentation it clearly says that strtotime() allows the
milliseconds but ignores them, which is fine for me. As you all see,
none of the three first options works with the colon or with AM/PM. The
only allowed syntax for milliseconds seems to be a normal dot without
any AM/PM (24 h-format) - which totally makes sense!
So I don't really know who's wrong here: PHP's strtotime() function or
some handling of date/time in the MS-SQL support provided by FreeTDS?
Anyway, my app broke since strtotime() can't parse the "raw" output
returned by the database server, I now have to set the
mssql.convertdatetime setting to off in order to get everything to work.
But I still think that the best option would be if maybe strtotime()
would be able to work with the default format returned by MS-SQL and
just ignore the milliseconds even if they're separated by a colon and
also allow the AM/PM format at the end? Or is Microsoft just wrong
here..? :)
I hope that any of this makes sense... :)
Greetings,
Krister Karlström, Helsinki, Finland
--
* Ing. Krister Karlström, Zend Certified Engineer *
* Systemutvecklare, IT-Centralen *
* Arcada - Nylands Svenska Yrkeshögskola *
* Jan-Magnus Janssons plats 1, 00550 Helsingfors, Finland *
* Tel: +358(20)7699699 GSM: +358(50)5328390 *
* E-mail: [EMAIL PROTECTED] *
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php