Bug #79442 [NEW]: Nth day of month can not be set

From: Date: Wed, 01 Apr 2020 07:38:07 +0000
Subject: Bug #79442 [NEW]: Nth day of month can not be set
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226381@lists.php.net to get a copy of this message
From:             michael dot vorisek at email dot cz
Operating system: 
PHP version:      7.4.4
Package:          Date/time related
Bug Type:         Bug
Bug description:Nth day of month can not be set

Description:
------------
Is it currently possible to use multiple modifications to a date like
"first day of -2 months, +15 days" in one modify() call?

Is it currently possible to to write one modify for "15th day of -2
months"?

Test script:
---------------
$d = new \DateTime('2020-03-28 12:00:00');

// first day of the month, ok
echo ((clone $d)->modify('last day of -2 months')->format('j.n.Y')) .
"\n";

// 15th day of the month - not working
echo ((clone $d)->modify('first day of -2 months, +15
days')->format('j.n.Y')) . "\n"; // bad result
echo ((clone $d)->modify('15th day of -2 months')->format('j.n.Y')) .
"\n"; // not parseable modify string

Expected result:
----------------
31.1.2020
15.1.2020
15.1.2020

Actual result:
--------------
31.1.2020
31.1.2020
Warning: DateTime::modify(): Failed to parse time string (15th day of -2
months) at position 0 (1)
Fatal error: Uncaught Error: Call to a member function format() on bool

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79442&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79442&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79442&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79442&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79442&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79442&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79442&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79442&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79442&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79442&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79442&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79442&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79442&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79442&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79442&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79442&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79442&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79442&r=mysqlcfg


Thread (6 messages)

« previous php.bugs (#226381) next »