Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] strtotime() in PHP 5.2.3 [RSS Feed]

#1 March 12, 2008 13:05:37

Krister K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] strtotime() in PHP 5.2.3


Hi!I'm currently working on a upgrade of a large PHP application from aSlackware Apache 1.x environment with PHP 5.0.4 to a Ubuntu Apache 2.2.4environment using PHP 5.2.3 (Ubuntu package). Since our databases arerunning on a MS-SQL 2000 server we're also using the FreeTDS librarywith the mssql-support in PHP.One thing I noticed is that the default datetime-format returned byMS-SQL/FreeTDS/whatever component invoked here has changed from the oldenvironment 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:000AMAs you can see the milliseconds have been added, but should notmilliseconds be separeted by a dot? Like 12:00:00.000? At least, that'sthe format strtotime() understands, if you remove the AM...As you all guess by now my application relies on passing thesmalldatetime columns returned directly from MS-SQL to the strtotime()function for getting the UNIX-time. I played around a bit to test whatformats 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: 1188162000In the documentation it clearly says that strtotime() allows themilliseconds 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. Theonly allowed syntax for milliseconds seems to be a normal dot withoutany AM/PM (24 h-format) - which totally makes sense!So I don't really know who's wrong here: PHP's strtotime() function orsome handling of date/time in the MS-SQL support provided by FreeTDS?Anyway, my app broke since strtotime() can't parse the "raw" outputreturned by the database server, I now have to set themssql.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 andjust ignore the milliseconds even if they're separated by a colon andalso allow the AM/PM format at the end? Or is Microsoft just wronghere..? :)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: *

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 March 12, 2008 17:56:39

Derick R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] strtotime() in PHP 5.2.3


On Wed, 12 Mar 2008, Krister Karlström wrote:

> 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..? :)

Sure, we can support this. Can you file a feature request please?

regards,
Derick--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 March 13, 2008 09:09:24

Krister K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] strtotime() in PHP 5.2.3


Derick Rethans wrote:On Wed, 12 Mar 2008, Krister Karlström wrote: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..? :)Sure, we can support this. Can you file a feature request please?OK. Here you are, #44426. Thank you for looking into this!

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: *

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] strtotime() in PHP 5.2.3 [RSS Feed]

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support