Bug #72586 [NEW]: wrong createfromformat for leap year

From: Date: Tue, 12 Jul 2016 16:09:14 +0000
Subject: Bug #72586 [NEW]: wrong createfromformat for leap year
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202246@lists.php.net to get a copy of this message
From:             stierlitz122 at gmail dot com
Operating system: ubuntu/windows
PHP version:      5.6.23
Package:          Date/time related
Bug Type:         Bug
Bug description:wrong createfromformat for leap year

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 bug report at https://bugs.php.net/bug.php?id=72586&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72586&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72586&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72586&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72586&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72586&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72586&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72586&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72586&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72586&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72586&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72586&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72586&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72586&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72586&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72586&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72586&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72586&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72586&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72586&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72586&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#202246) next »