Bug #69338 [NEW]: strtotime does not note, that a month can have 5 weeks
| From: | igor875126 at gmail dot com | Date: | Tue, 31 Mar 2015 08:59:21 +0000 |
| Subject: | Bug #69338 [NEW]: strtotime does not note, that a month can have 5 weeks | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191744@lists.php.net to get a copy of this message | ||
From: igor875126 at gmail dot com
Operating system: Linux
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:strtotime does not note, that a month can have 5 weeks
Description:
------------
The function strtotime('-1 month') does substract 4 weeks, but should
substract THE NUMBER OF DAYS IN MONTH
Example:
Our current date: 31.03.2015 // contains 5 weeks
$minusonemonth = date('Ymd', strtotime('-1 month'));
Returns:
20150303
It seems that "strtotime('-1 month');" just substracts 4 weeks
Solution:
-1 month should substract number of days in the month
Workarround:
$minusonemonth = date('Ymd', strtotime('-' . date('t') . '
day'));
Test script:
---------------
$minusonemonth = date('Ymd', strtotime('-1 month'));
--
Edit bug report at https://bugs.php.net/bug.php?id=69338&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69338&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69338&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69338&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69338&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69338&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69338&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69338&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69338&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69338&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69338&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69338&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69338&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69338&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69338&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69338&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69338&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69338&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69338&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69338&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69338&r=mysqlcfg