Bug #68161 [Opn->Ver]: DateTime->modify "first day of this month"
| From: | leigh@php.net | Date: | Wed, 08 Oct 2014 04:16:54 +0000 |
| Subject: | Bug #68161 [Opn->Ver]: DateTime->modify "first day of this month" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187945@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: leigh@php.net
Reported by: thunberg at gmail dot com
Summary: DateTime->modify "first day of this month"
-Status: Open
+Status: Verified
Type: Bug
Package: Date/time related
Operating System: Linux 2.6
PHP Version: 5.6.1
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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