|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-15 06:18 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 15:00:01 2025 UTC |
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.