Bug #68161 [Ana->Csd]: DateTime->modify "first day of this month"
| From: | derick@php.net | Date: | Fri, 11 Nov 2016 11:41:49 +0000 |
| Subject: | Bug #68161 [Ana->Csd]: DateTime->modify "first day of this month" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205304@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68161&edit=1
ID: 68161
Updated by: derick@php.net
Reported by: thunberg at gmail dot com
Summary: DateTime->modify "first day of this month"
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Linux 2.6
PHP Version: 5.6.1
Assigned To: leigh
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
This seems to work fine in PHP 5.6.27. It seems to have been fixed in 5.6.19 and 7.0.4: https://3v4l.org/S3iS8
Previous Comments:
------------------------------------------------------------------------
[2014-10-08 05:31:23] leigh@php.net
Patch submitted: https://github.com/php/php-src/pull/870
------------------------------------------------------------------------
[2014-10-08 04:16:54] leigh@php.net
Verified in 5.4, 5.5, 5.6 and master.
The documentation for setTimestamp() clearly states: "Sets the date and time based on an Unix
timestamp", however the date portion is not set in this case.
------------------------------------------------------------------------
[2014-10-05 23:13:05] thunberg at gmail dot com
Description:
------------
Using setTimestamp after modifying a DateTime object with "first day of this month" string
results in the incorrect date and time.
If "first day of this month" is replaced with something else like "tomorrow" it
works fine. For some reason the example below appears to lock in the date component, but not the
time.
Test script:
---------------
$time_start = new DateTime('2014-10-02');
echo $time_start->format('r') . "\n";
$time_start->modify('first day of this month');
echo $time_start->format('r') . "\n";
$time_start->setTimestamp(time());
echo $time_start->format('r') . "\n";
Expected result:
----------------
Current date and time
Actual result:
--------------
October 1st
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68161&edit=1