php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63360 Changelog may be incorrect
Submitted: 2012-10-25 11:20 UTC Modified: 2012-11-05 11:35 UTC
From: wachsmuth at cominto dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: windows
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: wachsmuth at cominto dot de
New email:
PHP Version: OS:

 

 [2012-10-25 11:20 UTC] wachsmuth at cominto dot de
Description:
------------
---
From manual page: http://www.php.net/datetime.modify
---

Hello,

the Changelog  says with PHP 5.3.6 "Absolute date/time statements now take effect"

I run following script with PHP 5.3.8. The first two times and the last time it is correct. But modify('now') does not set the date to "now" like setTimeStamp(time()). The documentation here is misleading



Test script:
---------------
$d = new DateTime();
$d->setTimeStamp(strtotime('2012-10-25'));
assertThis(25, $d);
$d->modify('-1 day');
assertThis(24, $d);

$d->modify('now');
assertThis(25, $d);

$d->setTimeStamp(time());
assertThis(25, $d);

function assertThis($expected, $actual) {
  print 'expected ' . $expected . ' - ' . $actual->format('d') . " actual\n";
}

Expected result:
----------------
expected 25 - 25 actual
expected 24 - 24 actual
expected 25 - 25 actual
expected 25 - 25 actual


Actual result:
--------------
expected 25 - 25 actual
expected 24 - 24 actual
expected 25 - 24 actual
expected 25 - 25 actual


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-26 17:51 UTC] hanskrentel at yahoo dot de
Thank you for taking the time to create a bug report. Actually you might 
have misunderstood something here. The documentation of 'now' is pretty 
clear about that:

---------

http://www.php.net/manual/en/datetime.formats.relative.php

'now'	Now - this is simply ignored

---------

For your understanding imagine you have got a DateTime object. It is the 
context in which you call the modify() function. Different to time() 
which has the system's time as a hidden dependency, the DateTime object 
has it's own time value as it's "dependency". 'Now' therefore is the now 
of that object instance, its own time value.

That is why you do not see any change if you modify a DateTime by 'now'.

It's not your systems now, but the now of the object.
 [2012-11-05 11:35 UTC] wachsmuth at cominto dot de
-Status: Open +Status: Closed
 [2012-11-05 11:35 UTC] wachsmuth at cominto dot de
okay thank you
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 08:00:02 2026 UTC