|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-01-07 10:21 UTC] daniz at rocketmail dot com
Description:
------------
Year is wrong in result based on test.
Test script:
---------------
$date = "2013-01-07";
echo date('W Y', strtotime("-1 week", strtotime($date)));
Expected result:
----------------
Should be "01 2013"
Actual result:
--------------
Result is "01 2012"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 08:00:02 2025 UTC |
Please try this: $date = "2013-01-07"; $earlier = strtotime("-1 week", strtotime($date)); // should result in 31 Dec 2012, which is a Monday echo date('r', $earlier); // to make sure we have the right date echo "\n"; echo date('W Y', $earlier); // what you have echo "\n"; echo date('W o', $earlier); // what I think you want echo "\n"; I ran it and got this: Mon, 31 Dec 2012 00:00:00 +0000 01 2012 01 2013