php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63927 Bogus week number with date + strtotime
Submitted: 2013-01-07 09:06 UTC Modified: 2013-01-07 10:37 UTC
From: tcheko at no-log dot org Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.4.10 OS: Linux
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: tcheko at no-log dot org
New email:
PHP Version: OS:

 

 [2013-01-07 09:06 UTC] tcheko at no-log dot org
Description:
------------
the test script returns date formated as year+week.

It should return a list of date like this:

...
201250
201251
201252
201301
201302
...

NB: increase $i if current weeknumber is greater than 14 to expose the bug.

Test script:
---------------
<?php
for($i = 15; $i >= 0; $i--) echo date("YW", strtotime("-$i week")) . "<br />";
?>


Expected result:
----------------
...
201250
201251
201252
201301
201302
...

Actual result:
--------------
...
201250
201251
201252
**201201**
201302
...



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-07 09:22 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2013-01-07 09:22 UTC] rasmus@php.net
There is no bug here. This is correct as per the ISO-8601 Date spec. The first 
week of the year is the week that contains the first Thursday. And weeks always 
start on Mondays. That means the first day of the first week is not always in the 
same calendar year as the first Thursday. Please read the ISO-8601 spec for more 
details.
 [2013-01-07 10:37 UTC] tcheko at no-log dot org
Replace Y with o for expected year. 

Definitly subtle, misleading and brain damaged.

for($i = 15; $i >= 0; $i--) echo date("oW", strtotime("-$i week")) . "<br />";
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 14:01:30 2024 UTC