Doc #62476 [Opn->Csd]: DateTime::createFromFormat z format incorrect wrt 29.02

From: Date: Fri, 01 Oct 2021 13:34:36 +0000
Subject: Doc #62476 [Opn->Csd]: DateTime::createFromFormat z format incorrect wrt 29.02
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19239@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62476&edit=1 ID: 62476 Updated by: git@php.net Reported by: kaido at tradenet dot ee Summary: DateTime::createFromFormat z format incorrect wrt 29.02 -Status: Open +Status: Closed Type: Documentation Problem Package: Date/time related Operating System: debian 2.6.32-5-amd64 PHP Version: 5.4.4 Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb69 Revision: https://github.com/php/doc-en/commit/a8f160fa977075f981c74bff2a68abb99c98f04d Log: Fix #62476: DateTime::createFromFormat z format incorrect wrt 29.02 Previous Comments: ------------------------------------------------------------------------ [2021-10-01 13:01:27] cmb@php.net Ah, just found that the change in PHP 8.0.10 is due to fixing bug #79580. Apparently, when the day-of-year is parsed before the given year, the day-of-year is applied to the current year. ------------------------------------------------------------------------ [2021-10-01 12:38:47] cmb@php.net As of PHP 8.0.10, it is no longer possible to use "z.Y" at all ("A 'day of year' can only come after a year has been found"). Fixing the unsupported format to "Y.z" brings the desired results[1]. So this is a documentation problem. [1] <https://3v4l.org/2In8R> ------------------------------------------------------------------------ [2016-06-14 12:18:19] cmb@php.net Related To: Bug #70956 ------------------------------------------------------------------------ [2015-03-10 09:14:44] info at giorgiosironi dot com Possible workaround: $ php -r 'echo DateTime::createFromFormat("z Y", "59 2016")->format("Y-m-d"), PHP_EOL;' 2016-03-01 $ php -r 'echo DateTime::createFromFormat("Y z", "2016 59")->format("Y-m-d"), PHP_EOL;' 2016-02-29 $ php -v PHP 5.4.31-1+deb.sury.org~precise+1 (cli) (built: Jul 25 2014 07:04:32) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.2, Copyright (c) 1999-2013, by Zend Technologies If it can be any helpful in Google searches for this bug, we encountered this when using MongoDB $dayOfYear aggregation option. ------------------------------------------------------------------------ [2015-02-03 19:40:05] kohenkatz at gmail dot com Why is this still an issue 2.5 years later? I see it in 5.5.12 on Ubuntu 14.10 and 5.6.5 on Windows Server 2012. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=62476 -- Edit this bug report at https://bugs.php.net/bug.php?id=62476&edit=1

« previous php.doc.bugs (#19239) next »