Bug #70186 [Com]: strtotime -1 month has a bug in 2015-07-31
| From: | vb2005xu at qq dot com | Date: | Mon, 03 Aug 2015 03:09:46 +0000 |
| Subject: | Bug #70186 [Com]: strtotime -1 month has a bug in 2015-07-31 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194920@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70186&edit=1
ID: 70186
Comment by: vb2005xu at qq dot com
Reported by: vb2005xu at qq dot com
Summary: strtotime -1 month has a bug in 2015-07-31
Status: Open
Type: Bug
Package: Date/time related
Operating System: all
PHP Version: 5.6.11
Block user comment: N
Private report: N
New Comment:
Is not just in July 31st, March 31st, May 31st, July 31st, October 31st, December 31st, there is
this problem, as long as the number of days in January is less than the current number of days will
appear this problem
Previous Comments:
------------------------------------------------------------------------
[2015-08-03 03:00:52] vb2005xu at qq dot com
Description:
------------
<?php
date_default_timezone_set('Asia/Shanghai');
$tn = strtotime("2015-07-31");
echo date('Y-m' , strtotime("-1 month",$tn));
// why output 2015-07 ?
Test script:
---------------
<?php
date_default_timezone_set('Asia/Shanghai');
$tn = strtotime("2015-07-31");
echo date('Y-m' , strtotime("-1 month",$tn));
Expected result:
----------------
2015-06
Actual result:
--------------
2015-07
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70186&edit=1