Bug #66453 [Nab]: Datetime modify bad result
| From: | requinix@php.net | Date: | Thu, 09 Jan 2014 23:24:57 +0000 |
| Subject: | Bug #66453 [Nab]: Datetime modify bad result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183681@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66453&edit=1
ID: 66453
Updated by: requinix@php.net
Reported by: mail at piotrantosik dot com
Summary: Datetime modify bad result
Status: Not a bug
Type: Bug
Package: *Calendar problems
Operating System: Linux
PHP Version: 5.5.7
Block user comment: N
Private report: N
New Comment:
December 31st, 2013 most certainly does exist, and it does in every Gregorian calendar-based system
around. That's not even up for discussion, it simply *is*.
As for your question, read the documentation for date() [1] to see that "W" is the ISO
8601 week number [2], which is a two digit zero-padded number.
[1] http://www.php.net/date
[2] http://en.wikipedia.org/wiki/ISO_8601#Week_dates
If you have questions, please ask on a mailing list or online forum to get more help.
http://www.php.net/support.php
Previous Comments:
------------------------------------------------------------------------
[2014-01-09 23:01:33] mail at piotrantosik dot com
You're right, arithmetic is correct but 31-12-2013 is not exist in any calendars.
Eg. i need display a week from this day:
$d->format('W') return 01 - but maybe throw a exception? why return 01??
------------------------------------------------------------------------
[2014-01-09 22:42:35] requinix@php.net
Are you saying that December 31st is not a day? Because it totally is.
The arithmetic is correct.
------------------------------------------------------------------------
[2014-01-09 22:35:25] mail at piotrantosik dot com
Description:
------------
DateTime object return non exist day in calendar.
Test script:
---------------
$d = new \DateTime('2014-01-08');
$d->modify('-8 day');
Expected result:
----------------
echo $d->format('Y-m-d')) //2013-12-30
Actual result:
--------------
echo $d->format('Y-m-d')) //2013-12-31
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66453&edit=1