Doc #77719 [NEW]: Behavior of strtotime() and new DateTime() documentation utterly insufficient
| From: | teo8976 at gmail dot com | Date: | Sun, 10 Mar 2019 17:19:18 +0000 |
| Subject: | Doc #77719 [NEW]: Behavior of strtotime() and new DateTime() documentation utterly insufficient | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-16457@lists.php.net to get a copy of this message | ||
From: teo8976 at gmail dot com
Operating system: all
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Behavior of strtotime() and new DateTime() documentation utterly insufficient
Description:
------------
http://php.net/manual/en/function.strtotime.php
http://php.net/manual/en/datetime.construct.php
http://php.net/manual/en/datetime.formats.php
In either of the above pages I expect to find the answer to the
question:
1 - What will be the result of new DateTime("Mon 00:01")?
2 - What will be the result of new DateTime("March 1 00:01")?
1 is not obvious because: is it next monday from now, or is it the
monday of the current week?
2 is not obvious because: is it next March 1 from now (i.e. March 1 of
next year if we are past March 1, and March 1 of this year if we are
before March 1)?
They are ESPECIALLY not obvious given that the answer is different in
the two cases. For week days, it's always in the future; for a given
month and day, instead, it is always in the current year, which may be
in the past or in the future.
Actually I now see that the answer to 1 is at
http://php.net/manual/en/datetime.formats.relative.php
but I don't see
the answer to 2 anywhere.
Also I'm not sure why (1) would be considered a "relative" format while
(2) wouldn't (they both depend on the current time), so why woundn't the
answer to 2 be found at
http://php.net/manual/en/datetime.formats.relative.php
too?
One way of seeing this is that (1) is "relative" by definition, while
(2) is an "absolute" time string where a part (the year) is missing, and
in that case the missing part is taken from the current time. If this is
the explanation, I'd expect to find it in the documentation. It's a lot
to guess.
The only way I could figure this out was by trying a few values.
--
Edit bug report at https://bugs.php.net/bug.php?id=77719&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77719&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77719&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77719&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77719&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77719&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77719&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77719&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77719&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77719&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77719&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77719&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77719&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77719&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77719&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77719&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77719&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77719&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77719&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77719&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77719&r=mysqlcfg