php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70956 DayOfYear ignores leap years
Submitted: 2015-11-22 17:18 UTC Modified: 2016-06-14 12:18 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: braunert at bitsol dot de Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: Irrelevant OS: irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 - 11 = ?
Subscribe to this entry?

 
 [2015-11-22 17:18 UTC] braunert at bitsol dot de
Description:
------------
The function DateTime::createFromFormat('z Y', "59 2016") return false values if there is a leap year.
I can't check it with DateTime::createFromFormat('z', "59"), because the leap year is next year, maybe than it's ok - but I don't think so.

This bug is reported earlier, but till now not fixed.

Test script:
---------------
$date = DateTime::createFromFormat('z Y', "58 2016");
echo $date->format('j. M. Y')."<br>"; // Result: 28. Feb. 2016
						
$date = DateTime::createFromFormat('z Y', "59 2016");
echo $date->format('j. M. Y')."<br>"; // Result: 1. Mar. 2016

$date = DateTime::createFromFormat('d m Y', "29 02 2016");
echo $date->format('j. M. Y')."<br>"; // Result: 29. Feb. 2016

$number = cal_days_in_month(CAL_GREGORIAN, 2, 2016); // 29
echo "$number";

Expected result:
----------------
28. Feb. 2016
29. Feb. 2016
29. Feb. 2016
29


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 12:18 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-06-14 12:18 UTC] cmb@php.net
> This bug is reported earlier, but till now not fixed.

Nevertheless, please don't report bugs twice.

Closing as duplicate of bug #62476.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 21:01:27 2019 UTC