Doc #77719 [Com]: Behavior of strtotime() and new DateTime() documentation utterly insufficient

From: Date: Sun, 10 Mar 2019 17:29:06 +0000
Subject: Doc #77719 [Com]: Behavior of strtotime() and new DateTime() documentation utterly insufficient
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16458@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77719&edit=1 ID: 77719 Comment by: teo8976 at gmail dot com Reported by: teo8976 at gmail dot com Summary: Behavior of strtotime() and new DateTime() documentation utterly insufficient Status: Open Type: Documentation Problem Package: Documentation problem Operating System: all PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Oh my. The information at http://php.net/manual/en/datetime.formats.relative.php is not even correct, or at least not unambiguous, in providing an answer to my question number 1. It says: > dayname Moves to the next day of this name. If you write "Sun 13:00" and today is Sunday, it's completely unclear whether it's going to "move" to next sunday, or if the result is today. Actually, "move" strongly suggests that it will move to next sunday, but the actual behavior is that it will result in today (and that's regardless of whether the hour (if included in the time string) has already passed or not). Previous Comments: ------------------------------------------------------------------------ [2019-03-10 17:19:18] teo8976 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=77719&edit=1

« previous php.doc.bugs (#16458) next »