Bug #75012 [NEW]: strtotime('-x month') has an unexpected behavior
| From: | paladinotoldo at gmail dot com | Date: | Mon, 31 Jul 2017 20:57:50 +0000 |
| Subject: | Bug #75012 [NEW]: strtotime('-x month') has an unexpected behavior | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-210436@lists.php.net to get a copy of this message | ||
From: paladinotoldo at gmail dot com
Operating system: any
PHP version: 7.0.21
Package: *General Issues
Bug Type: Bug
Bug description: strtotime('-x month') has an unexpected behavior
Description:
------------
---
From manual page: http://www.php.net/function.strtotime
---
strtotime('-1 month') has an unexpected behavior in 31th day of month
Test script:
---------------
$t =strtotime('31-07-2017');
echo "\n". date('d/m/Y',$t );
$timestamp = strtotime('-1 month',$t );
echo "\n".date("d/m/Y", $timestamp);
$timestamp = strtotime('-2 month',$t );
echo "\n". date("d/m/Y", $timestamp);
$timestamp = strtotime('-3 month',$t );
echo "\n". date("d/m/Y", $timestamp);
$timestamp = strtotime('-4 month',$t );
echo "\n". date("d/m/Y", $timestamp);
$timestamp = strtotime('-5 month',$t );
echo "\n". date("d/m/Y", $timestamp);
Expected result:
----------------
31/07/2017
30/06/2017
31/05/2017
30/04/2017
31/03/2017
28/02/2017
or
31/07/2017
01/07/2017
01/06/2017
02/05/2017
02/04/2017
03/03/2017
Actual result:
--------------
31/07/2017
01/07/2017
31/05/2017
01/05/2017
31/03/2017
03/03/2017
--
Edit bug report at https://bugs.php.net/bug.php?id=75012&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75012&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75012&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75012&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75012&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75012&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75012&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75012&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75012&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75012&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75012&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75012&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75012&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75012&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75012&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75012&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75012&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75012&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75012&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75012&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75012&r=mysqlcfg