|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63929 wrong year in strtotime
Submitted: 2013-01-07 10:21 UTC Modified: 2013-01-07 15:37 UTC
From: daniz at rocketmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: daniz at rocketmail dot com
New email:
PHP Version: OS:


 [2013-01-07 10:21 UTC] daniz at rocketmail dot com
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"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-07 12:43 UTC] r07271368 at hotmail dot com
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
 [2013-01-07 13:11 UTC] daniz at rocketmaik dot com
Indeed you're assumption is correct.
Reading the info regarding the 'o' gives meening why I'm seeing what I'm seeing.

 [2013-01-07 15:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

As the other commenter said, for the ISO Year, you need the "o".
 [2013-01-07 15:37 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 18:01:30 2024 UTC