Bug #74610 [Opn->Nab]: date function returns wrong value
| From: | requinix@php.net | Date: | Thu, 18 May 2017 11:34:26 +0000 |
| Subject: | Bug #74610 [Opn->Nab]: date function returns wrong value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209180@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74610&edit=1
ID: 74610
Updated by: requinix@php.net
Reported by: shivamkss at gmail dot com
Summary: date function returns wrong value
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Mac OS Sierra
PHP Version: 7.1.5
Block user comment: N
Private report: N
New Comment:
2017-05-31 + 1 month = 2017-06-31 and that overflows to 2017-07-01.
If your application needs it to stay as the last day of the month (not overflow) then you need
custom logic for that. For example, https://3v4l.org/SjYiE
Previous Comments:
------------------------------------------------------------------------
[2017-05-18 11:03:09] shivamkss at gmail dot com
Description:
------------
date function is returning 2017-07 while adding 1 month to "2017-05-31 09:00:00". My time
zone is Asia/Calcutta.
Test script:
---------------
$ââdate = "2017-05-31 09:00:00";
return date("Y-m",strtotime("+1 month", strtotime($date)));
Expected result:
----------------
It should return 2017-06
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74610&edit=1