php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44426 support for new format of milliseconds in strtotime()
Submitted: 2008-03-13 08:05 UTC Modified: 2008-03-13 15:54 UTC
From: krister dot karlstrom at arcada dot fi Assigned: derick (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5.2.5 OS: Ubuntu
Private report: No CVE-ID: None
 [2008-03-13 08:05 UTC] krister dot karlstrom at arcada dot fi
Description:
------------
The default datestring format returned by MS-SQL 2000 through the MS-SQL support in PHP 5.2.3 (Ubuntu package) using the provided FreeTDS library contains milliseconds that are separated with a colon, not a dot. This breaks the parsing of the datestring in strtotime(), which only seems to allow milliseconds separated by a dot. For compatibility it would be great if strtotime() also could parse these strings.

This is the format returned by MS-SQL 2000 from a datetime column:
Aug 27 2007 12:00:00:000AM

I hereby request that strtotime() should be able to parse this string, with our without the AM/PM (using 12 h or 24 h-format). For compatibility issues it would probably also be good if strtotime() could parse the string Aug 27 2007 12:00:00.000AM, since it for now doesn't allow the 12 h-format together with milliseconds.

Reproduce code:
---------------
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"); 

Expected result:
----------------
TIME: 1188162000 
TIME: 1188162000 
TIME: 1188205200
TIME: 1188205200
TIME: 1188162000
TIME: 1188162000
TIME: 1188162000 

Actual result:
--------------
TIME:
TIME:
TIME:
TIME: 1188205200
TIME: 1188162000
TIME: 1188162000
TIME: 1188162000 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-13 10:27 UTC] johannes@php.net
Assigned to Derick
 [2008-03-13 15:54 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 04:01:30 2024 UTC