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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC