|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66019 DateTime object does not support short ISO 8601 time format - YYYY-MM-DDTHH
Submitted: 2013-11-02 00:25 UTC Modified: 2017-10-24 05:24 UTC
From: kaldari at gmail dot com Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.5.5 OS: MacOS X
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-11-02 00:25 UTC] kaldari at gmail dot com
According to ISO 8601, the following is a valid date-time representation:
(representing 2 February 2012, 10:00)

However, PHP throws an error if the minutes are not specified.

Test script:
$tz = new DateTimeZone("Europe/Amsterdam");
$dateObject = new DateTime( '2012-02-02T10', $tz );
echo $dateObject->format( 'j F Y H:i' );

Expected result:
2 February 2012 10:00

Actual result:
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (2012-02-02T10) at position 11 (1): Unexpected character'


bug66019.patch (last revision 2016-08-07 16:35 UTC by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-03 11:43 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2016-08-07 16:35 UTC]
The following patch has been added/updated:

Patch Name: bug66019.patch
Revision:   1470587717
 [2016-08-07 16:35 UTC]
-Status: Assigned +Status: Verified
 [2016-08-07 16:35 UTC]
Confirmed: <>.

However, not only YYYY-MM-DDThh is allowed by ISO 8601, but also
hh, and as the date time parser is rather liberal wrt. its input,
also h would make sense. The respective fix is trivial (see
bug66019.patch), but it would now allow some somewhat doubtful
input to be successfully parsed, for instance, '3' (=> 03:00:00)
and '03-03' (=> 03:00:00-03:00). Not sure, if that's desirable.

Derick, what do you think?
 [2017-10-24 05:24 UTC]
-Status: Verified +Status: Assigned
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jan 15 15:01:23 2021 UTC