php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55799 DateTime::setISODate allows weeks to overflow in the next year
Submitted: 2011-09-27 13:01 UTC Modified: 2011-12-04 00:53 UTC
From: paul dot borgermans at gmail dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: 5.3.8 OS: Ubuntu / Mac OSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: paul dot borgermans at gmail dot com
New email:
PHP Version: OS:

 

 [2011-09-27 13:01 UTC] paul dot borgermans at gmail dot com
Description:
------------
This is actually a nice feature for calender data/time operations, but not documented yet:

Specifying a week number larger than valid for the year, the end results nicely overflows into the next year.



Test script:
---------------
<?php
echo date( ’W’, strtotime( "December 28th, 2011" ) ), "\n";
$ndate = new DateTime();
$ndate->setISODate(2011,56,07);
echo "ndate: " . $ndate->format('Y-m-d') . "\n";
$ndate->setISODate(2012,04,07);
echo "ndate: " . $ndate->format('Y-m-d') . "\n";
?>

Expected result:
----------------
52
ndate: 2012-01-29 
ndate: 2012-01-29 

Actual result:
--------------
52
ndate: 2012-01-29 
ndate: 2012-01-29 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-04 00:53 UTC] frozenfire@php.net
-Status: Open +Status: Wont fix
 [2011-12-04 00:53 UTC] frozenfire@php.net
It's implied in the Date Formats 
(http://php.net/manual/en/datetime.formats.date.php) that dates overflow. It 
doesn't specifically indicate weeks, but it does show examples for days and 
months.

I don't feel it's worth mentioning this specifically for weeks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC