Bug #72586 [Opn->Ver]: wrong createfromformat for leap year
| From: | cmb@php.net | Date: | Tue, 12 Jul 2016 19:02:22 +0000 |
| Subject: | Bug #72586 [Opn->Ver]: wrong createfromformat for leap year | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202253@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72586&edit=1
ID: 72586
Updated by: cmb@php.net
Reported by: stierlitz122 at gmail dot com
Summary: wrong createfromformat for leap year
-Status: Open
+Status: Verified
Type: Bug
Package: Date/time related
Operating System: ubuntu/windows
PHP Version: 5.6.23
Block user comment: N
Private report: N
New Comment:
Confirmed: <https://3v4l.org/ei8A2>.
Previous Comments:
------------------------------------------------------------------------
[2016-07-12 16:09:14] stierlitz122 at gmail dot com
Description:
------------
When using day of the year character 'z' with 'Y' for creation date - order is
important, but not important when using 'd-m-Y'.
---
From manual page: http://www.php.net/datetime.createfromformat
---
Test script:
---------------
<?php
$date1 = DateTime::createFromFormat('z Y', "59 2016"); //wrong with leap year
$date2 = DateTime::createFromFormat('Y z', "2016 59"); //correct
$date3 = DateTime::createFromFormat('d-m-Y', "29-02-2016"); //correct
$date4 = DateTime::createFromFormat('Y-m-d', "2016-02-29"); //correct
// let's see:
print $date1->format("z Y")."\n"; //60 2016
print $date2->format("z Y")."\n"; //59 2016
print $date3->format("z Y")."\n"; //59 2016
print $date4->format("z Y")."\n"; //59 2016
Expected result:
----------------
59 2016
59 2016
59 2016
59 2016
Actual result:
--------------
60 2016
59 2016
59 2016
59 2016
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72586&edit=1