|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54316 DateTime::createFromFormat does not handle trailing '|' correctly
Submitted: 2011-03-19 12:34 UTC Modified: 2011-03-21 10:41 UTC
From: gtisza at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.6 OS: Windows XP, Debian 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: gtisza at gmail dot com
New email:
PHP Version: OS:


 [2011-03-19 12:34 UTC] gtisza at gmail dot com
From manual page:

According to the documentation:

| - Resets all fields (year, month, day, hour, minute, second, fraction and timzone information) to the Unix Epoch if they have not been parsed yet

Y-m-d| will set the year, month and day to the information found in the string to parse, and sets the hour, minute and second to 0.

Actually, it fails to parse the date (but works correctly when | is not at the end of the string).

Tested on PHP 5.3.2/Win XP and PHP 5.3.5/Debian. Can't test on 5.3.6 right now as seems unavailable.

Test script:
var_dump(DateTime::createFromFormat('Y-m-d|', '2011-02-02'));
$errors = DateTime::getLastErrors();

Expected result:
object(DateTime)#1 (3) {
  string(19) "2011-02-02 00:00:00"
  string(15) "Europe/Budapest"

array(0) {

Actual result:

array(1) {
  string(12) "Data missing"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-21 06:03 UTC]
-Status: Open +Status: Verified
 [2011-03-21 06:03 UTC]
Confirmed on a current 5.3 SVN build.
 [2011-03-21 10:29 UTC]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2011-03-21 10:41 UTC]
Automatic comment from SVN on behalf of aharvey
Log: Fix bug #54316 (DateTime::createFromFormat does not handle trailing '|'
 [2011-03-21 10:41 UTC]
-Status: Assigned +Status: Closed
 [2011-03-21 10:41 UTC]
This bug has been fixed in SVN.

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

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 06:01:31 2024 UTC