Bug #66453 [Nab]: Datetime modify bad result

From: Date: Thu, 09 Jan 2014 23:01:33 +0000
Subject: Bug #66453 [Nab]: Datetime modify bad result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183680@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 User updated by: mail at piotrantosik dot com 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: 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?? Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#183680) next »