Bug #63970 [Opn->Nab]: Wrong year on week calculation from 2012-12-30
| From: | derick@php.net | Date: | Fri, 11 Jan 2013 16:51:43 +0000 |
| Subject: | Bug #63970 [Opn->Nab]: Wrong year on week calculation from 2012-12-30 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175961@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63970&edit=1
ID: 63970
Updated by: derick@php.net
Reported by: obibann at hotmail dot com
Summary: Wrong year on week calculation from 2012-12-30
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: RedHat EL 6.2
PHP Version: 5.3.20
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is not a bug. "Y" is the real year, where as "o" is the ISO year. The
"W" denotes the "ISO Week number" which ties in into the "ISO Year".
Please refer to http://en.wikipedia.org/wiki/ISO_week for the back
story.
When you run your script with "o" instead of "Y", the answer is the correct
"201152":
<?php
date_default_timezone_set("Europe/Paris");
echo date("o-W",strtotime("2012-12-30 11:00 -52 week")), "\n";
?>
Shows:
2011-52
Previous Comments:
------------------------------------------------------------------------
[2013-01-11 16:34:42] obibann at hotmail dot com
Erratum :
I think it should return "201152"
------------------------------------------------------------------------
[2013-01-11 16:31:28] obibann at hotmail dot com
Description:
------------
Set your server on December 30 2012:
date -s "20121230 11:00"
Ask PHP to give you the year and week 52 weeks ago thanks to the code below.
PHP prints "201252" instead of "201201"
No problems from other dates of with another value of week.
Test script:
---------------
date_default_timezone_set("Your/Timezone"); // For me Europe/Paris
echo date("YW",strtotime("-52 week"));
Expected result:
----------------
201201
Actual result:
--------------
201252
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63970&edit=1