php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46268 When call DateTime#setTime, it seems to be called the last modify method too
Submitted: 2008-10-10 04:27 UTC Modified: 2008-12-18 20:32 UTC
From: shimooka at doyouphp dot jp Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3CVS-2008-11-11 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shimooka at doyouphp dot jp
New email:
PHP Version: OS:

 

 [2008-10-10 04:27 UTC] shimooka at doyouphp dot jp
Description:
------------
When I call DateTime#setTime, it seems to be called the last modify method too. If I use date_time_set function, I get the same result.

This report is similar to Bug #41599, but differ from #41599 in using 'time'(01:02:03).

With PHP5.2.6, I get the expected result.

Reproduce code:
---------------
<?php
date_default_timezone_set('Asia/Tokyo');

$now = new DateTime('2008-10-10 01:02:03');
echo $now->format("Y-m-d H:i:s") . PHP_EOL;

$now->modify("1 day after");
echo $now->format("Y-m-d H:i:s") . PHP_EOL;

$now->modify("1 hour after");
echo $now->format("Y-m-d H:i:s") . PHP_EOL;

$now->setTime(0, 0, 0);
//date_time_set($now, 0, 0, 0);
echo $now->format("Y-m-d H:i:s") . PHP_EOL;


Expected result:
----------------
2008-10-10 01:02:03
2008-10-11 01:02:03
2008-10-11 02:02:03
2008-10-11 00:00:00


Actual result:
--------------
2008-10-10 01:02:03
2008-10-11 01:02:03
2008-10-11 02:02:03
2008-10-11 01:00:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 20:32 UTC] derick@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-02-10 16:23 UTC] svn@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&revision=294854
Log: - Added a test case for bug #45866
- Fixed tests: oo_002, bug46268
- Fixed bug #50930 (Wrong date by php_date.c patch with ancient gcc/glibc
  versions).
- Make sure faulty strings passed to DateTime::modify() notify the user.
- Revert fix for bug #50392 as it was fixed wrongly without a proper test case.
- Fixed a bug with the 'r' formatting function as the default buffer size that
  was allocated only fit 4 digit years.
 [2010-02-11 11:11 UTC] svn@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=294880
Log: - merge fix for: #45866,#50930, revert fix for #50392, Fixed a bug with the 'r' formatting function, added or fixed tests for #45866 and #46268
 [2010-08-02 11:53 UTC] shaffy at visionaspire dot com
Thanks,nice post.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC