php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76838 date_parse_from_format() changed meaning of zone value in PHP 7.2 -> BC break
Submitted: 2018-09-04 15:31 UTC Modified: 2018-09-09 15:43 UTC
From: me at vasekpurchart dot cz Assigned: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: 7.2.9 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at vasekpurchart dot cz
New email:
PHP Version: OS:

 

 [2018-09-04 15:31 UTC] me at vasekpurchart dot cz
Description:
------------
In PHP 7.2 the result returned from date_parse_from_format() for `zone` parameter differs in moving from returning value in minutes to seconds and also the positive/negative sign differs.

This is a BC break and should have been at least documented, but I have not found any mention of this in any of the http://php.net/manual/en/migration72.php links.

Test script:
---------------
<?php

// runnable version with results https://3v4l.org/4vajJ

$format = 'Y-m-d\TH:i:sO';
$timeString = '2018-09-04T16:15:55+0200';
$parsedTime = date_parse_from_format($format, $timeString);
var_dump($parsedTime);

Expected result:
----------------
int(-120)

Actual result:
--------------
int(7200)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-04 18:53 UTC] me at vasekpurchart dot cz
Sorry, posted slightly different version of test script originally (when I tried to debug if there are more differences in the parsed result).

Updated:

Test script:
---------------
<?php

// runnable version with results https://3v4l.org/4gtdS

$format = 'Y-m-d\TH:i:sO';
$timeString = '2018-09-04T16:15:55+0200';
$parsedTime = date_parse_from_format($format, $timeString);
var_dump($parsedTime['zone']);
 [2018-09-09 14:53 UTC] cmb@php.net
The behavioral change has been introduced by commit a063d55[1]
(which later has been reverted for branches lower than PHP-7.2).
I assume that the change is intentional, and I'm not sure whether
it constitutes a BC break, since the DateTime properties might be
regarded as private (what would have to be documented).

[1] <http://git.php.net/?p=php-src.git;a=commit;h=a063d55395c818c401b7efdf6b42b4728ce3df08>
 [2018-09-09 15:01 UTC] derick@php.net
It was intentional, and should be in the docs and in the upgrading guide.
 [2018-09-09 15:10 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2018-09-09 15:10 UTC] cmb@php.net
Thanks, Derick!
 [2018-09-09 15:42 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=345615
Log: Fix #76838: date_parse_from_format() changed meaning of zone value in PHP 7.2 -&gt; BC break
 [2018-09-09 15:43 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2018-09-09 15:43 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2018-09-10 11:12 UTC] me at vasekpurchart dot cz
Thank you for resolving this so quickly and documenting the change.
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=31af10a4a2591cf2f5ec04c599de5652cf159aa8
Log: Fix #76838: date_parse_from_format() changed meaning of zone value in PHP 7.2 -&gt; BC break
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 21:01:28 2024 UTC