Bug #66019 [Asn]: DateTime object does not support short ISO 8601 time format - YYYY-MM-DDTHH

From: Date: Wed, 07 Apr 2021 09:34:45 +0000
Subject: Bug #66019 [Asn]: DateTime object does not support short ISO 8601 time format - YYYY-MM-DDTHH
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233284@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66019&edit=1

 ID:                 66019
 Updated by:         derick@php.net
 Reported by:        kaldari at gmail dot com
 Summary:            DateTime object does not support short ISO 8601 time
                     format - YYYY-MM-DDTHH
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   MacOS X
 PHP Version:        5.5.5
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

@cmb, your patch breaks:

derick@gargleblaster:~/dev/derickr-timelib$ ./tests/tester-parse-string "14/10/2006"
E=2 TS: 0 | -99999-10-20 14:00:00
Errors found while parsing '14/10/2006'
E Unexpected character @ pos 2 (char=[/])
E Double time specification @ pos 8 (char=[0])

derick@gargleblaster:~/dev/derickr-timelib$ ./tests/tester-parse-string "13/10/2006"
E=2 TS: 0 | -99999-10-20 13:00:00
Errors found while parsing '13/10/2006'
E Unexpected character @ pos 2 (char=[/])
E Double time specification @ pos 8 (char=[0])

So unless you're really invested in this, I'm likely to close this.


Previous Comments:
------------------------------------------------------------------------
[2016-08-07 16:35:33] cmb@php.net

Confirmed: <https://3v4l.org/Wpjs0>.

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?

------------------------------------------------------------------------
[2016-08-07 16:35:17] cmb@php.net

The following patch has been added/updated:

Patch Name: bug66019.patch
Revision:   1470587717
URL:        https://bugs.php.net/patch-display.php?bug=66019&patch=bug66019.patch&revision=1470587717

------------------------------------------------------------------------
[2013-11-02 00:25:39] kaldari at gmail dot com

Description:
------------
According to ISO 8601, the following is a valid date-time representation:
2012-02-02T10
(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'


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66019&edit=1


Thread (8 messages)

« previous php.bugs (#233284) next »