Bug #65657 [Com]: DatePeriod doesn't accept valid ISO-8601 formats (timezone problem)
Edit report at https://bugs.php.net/bug.php?id=65657&edit=1
ID: 65657
Comment by: jc at unternet dot net
Reported by: glavic at gmail dot com
Summary: DatePeriod doesn't accept valid ISO-8601 formats
(timezone problem)
Status: Open
Type: Bug
Package: Date/time related
Operating System: ALL
PHP Version: 7.1
Block user comment: N
Private report: N
New Comment:
I'm working on it. meanwhile you can use:
$periods = new DatePeriod(new DateTime("2013-09-09T12:00:15+02:00"), new
DateInterval("P1D"), 2);
Previous Comments:
------------------------------------------------------------------------
[2013-09-12 08:51:44] glavic at gmail dot com
Description:
------------
The ISO-8601 states the following: "The offset from UTC is given in the format ±[hh]:[mm],
±[hh][mm], or ±[hh].". But DatePeriod accepts only $iso formats that are in UTC (flag Z).
See test script.
I have tried all possible combinations to set timezone correctly, but no success:
http://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators
Test script:
---------------
<?php
$iso = 'R2/2013-09-09T12:00:15Z/P1D';
$periods = new DatePeriod($iso);
var_dump( is_object($periods) );
$iso = 'R2/2013-09-09T12:00:15+02:00/P1D';
$periods = new DatePeriod($iso);
var_dump( is_object($periods) );
Run this on multiple PHP versions: http://3v4l.org/b4n9j
Expected result:
----------------
bool(true)
bool(true) # with correct offset ofc
Actual result:
--------------
bool(true)
Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct():
Unknown or bad format (R2/2013-09-09T12:00:15+02:00/P1D)' in ...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65657&edit=1
Thread (3 messages)