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

Pull Requests

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: Sat Dec 21 13:01:31 2024 UTC