Bug #51737 [Csd]: Having a bug when using date_diff($t1,$t2)
| From: | aharvey@php.net | Date: | Tue, 04 May 2010 10:07:37 +0000 |
| Subject: | Bug #51737 [Csd]: Having a bug when using date_diff($t1,$t2) | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4305@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51737&edit=1
ID: 51737
Updated by: aharvey@php.net
Reported by: iggukk at gmail dot com
Summary: Having a bug when using date_diff($t1,$t2)
Status: Closed
Type: Bug
Package: Documentation problem
Operating System: Win XP
PHP Version: 5.3.2
Assigned To: aharvey
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Added an example anyway, just to be on the safe side. :)
Previous Comments:
------------------------------------------------------------------------
[2010-05-04 12:07:01] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=298955
Log: Added an example to make clearer the misunderstanding that led to
bug #51737
(Having a bug when using date_diff($t1,$t2)).
------------------------------------------------------------------------
[2010-05-04 11:23:07] iggukk at gmail dot com
Thanks a lot, aharvey you're great.
I should have figured there was something to find in the format but my
mind is kinda stuck this morning.
Nevermind about the documentation. I should have guessed that there were
more tags than %d. Like in all the date/time functions (doh!).
I guess I deserve a /slap for that.
Going back to work. Thanks again.
------------------------------------------------------------------------
[2010-05-04 11:11:07] aharvey@php.net
Not a bug, since you probably want %a (which is the total number of days
in the interval) rather than %d.
%d only shows the number of days left over after date_diff() has
calculated the number of months and years: in your first example, the
interval is basically "1 month 0 days", so %d returns 0. (If you try "%m
month(s) %d day(s)" as the format string, that will probably be a bit
clearer.)
Nevertheless, the documentation could probably be a touch clearer on
this point. Morphing into a documentation bug; I'll see if I can make it
a bit more obvious in one of the examples what %d does.
------------------------------------------------------------------------
[2010-05-04 11:04:01] iggukk at gmail dot com
Huh, sorry about that, and thanks for answering so quickly.
echo $interval->format('%R%d days');
simply from the example on php manual.
Just tried to feed the dates in different formats like 12.04.2010 and
12.03.2010, (instead of 2010-04-12) it seems to give the same result in
final.
------------------------------------------------------------------------
[2010-05-04 10:57:43] aharvey@php.net
The test script you've provided doesn't work, since echoing a
DateInterval object isn't supported. How are you actually outputting
$interval?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=51737
--
Edit this bug report at http://bugs.php.net/bug.php?id=51737&edit=1