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
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
33 - 27 = ?
Subscribe to this entry?

 
 [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: Tue Apr 23 10:01:29 2024 UTC