#43849 [Opn->Bgs]: date('YW', strtotime('2007-12-31')) return 200701
| From: | derick@php.net | Date: | Tue, 15 Jan 2008 07:12:34 +0000 |
| Subject: | #43849 [Opn->Bgs]: date('YW', strtotime('2007-12-31')) return 200701 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121288@lists.php.net to get a copy of this message | ||
ID: 43849
Updated by: derick@php.net
Reported By: kiange at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Ubuntu
PHP Version: 5.2.5
New Comment:
This is correct, the "W" shows the ISO week, which you need to match
against the ISO year specifier ("o" - small "O"). ISO Week 2008-01 goes
from Dec 31st to Jan 6th. This will return what you expect:
echo date('Yo', strtotime('2007-12-31')), "\n";
strftime() would not be good to rely on, as the output might differ on
other operating systems.
Previous Comments:
------------------------------------------------------------------------
[2008-01-15 06:18:31] kiange at gmail dot com
Description:
------------
Enviornments:
PHP 5.2.3-1ubuntu6.2
Reproduce code:
---------------
echo date('YW', strtotime('2007-12-31'));
// return 200701, maybe 200801 according to the reference page
echo strftime("%Y%W",strtotime("2007-12-31"));
// return 200753
Expected result:
----------------
200753 or 200801
Actual result:
--------------
200701
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43849&edit=1