|  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:
Solve the problem:
46 + 37 = ?
Subscribe to this entry?

 [2011-09-27 13:01 UTC] paul dot borgermans at gmail dot com
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:
echo date( ’W’, strtotime( "December 28th, 2011" ) ), "\n";
$ndate = new DateTime();
echo "ndate: " . $ndate->format('Y-m-d') . "\n";
echo "ndate: " . $ndate->format('Y-m-d') . "\n";

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-04 00:53 UTC]
-Status: Open +Status: Wont fix
 [2011-12-04 00:53 UTC]
It's implied in the Date Formats 
( that dates overflow. It 
doesn't specifically indicate weeks, but it does show examples for days and 

I don't feel it's worth mentioning this specifically for weeks.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jan 31 01:05:52 2023 UTC