Bug #78080 [NEW]: strtotime('last <day of week> + 7 days') incorrect result
| From: | romash1408 at yandex dot ru | Date: | Wed, 29 May 2019 03:29:20 +0000 |
| Subject: | Bug #78080 [NEW]: strtotime('last <day of week> + 7 days') incorrect result | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221035@lists.php.net to get a copy of this message | ||
From: romash1408 at yandex dot ru
Operating system: UNIX
PHP version: 7.3.5
Package: Date/time related
Bug Type: Bug
Bug description:strtotime('last <day of week> + 7 days') incorrect result
Description:
------------
Today is 2019-05-29, wednesday.
In any php 7.* interpreter I write
echo date('Y-m-d', strtotime('last wednesday'));
and get last week's day (2019-05-22)
echo date('Y-m-d', strtotime('last wednesday + 1 day'));
shows correct date too (2019-05-23)
But
echo date('Y-m-d', strtotime('last wednesday + 7 day'));
gives result like 'last wednesday' was today (2019-06-05)
Live example on Ideone: https://ideone.com/1YzDpS
php 5.6 doesn't have this bug!
Test script:
---------------
$day = date("l");
echo date("Y-m-d", strtotime("last $day")) . "\n";
echo date("Y-m-d", strtotime("last $day + 1 day")) . "\n";
echo date("Y-m-d", strtotime("last $day + 6 day")) . "\n";
echo date("Y-m-d", strtotime("last $day + 7 day")) . "\n";
Expected result:
----------------
2019-05-21
2019-05-22
2019-05-27
2019-05-28
Actual result:
--------------
2019-05-21
2019-05-22
2019-05-27
2019-06-04
--
Edit bug report at https://bugs.php.net/bug.php?id=78080&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78080&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78080&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78080&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78080&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78080&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78080&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78080&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78080&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78080&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78080&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78080&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78080&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78080&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78080&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78080&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78080&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78080&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78080&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78080&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78080&r=mysqlcfg