Bug #63929 [Opn->Nab]: wrong year in strtotime
| From: | derick@php.net | Date: | Mon, 07 Jan 2013 15:37:42 +0000 |
| Subject: | Bug #63929 [Opn->Nab]: wrong year in strtotime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175819@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63929&edit=1
ID: 63929
Updated by: derick@php.net
Reported by: daniz at rocketmail dot com
Summary: wrong year in strtotime
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
PHP Version: Irrelevant
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
As the other commenter said, for the ISO Year, you need the "o".
Previous Comments:
------------------------------------------------------------------------
[2013-01-07 13:11:09] 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.
Thanks
------------------------------------------------------------------------
[2013-01-07 12:43:06] 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 10:21:46] 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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63929&edit=1