Bug #72425 [Dup]: strtotime() should return false when string contains white space

From: Date: Fri, 13 May 2022 14:05:59 +0000
Subject: Bug #72425 [Dup]: strtotime() should return false when string contains white space
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241499@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72425&edit=1 ID: 72425 Updated by: derick@php.net Reported by: alex at itc77 dot com Summary: strtotime() should return false when string contains white space Status: Duplicate Type: Bug Package: Date/time related PHP Version: 7.0.7 Assigned To: cmb Block user comment: N Private report: N New Comment: I'm closing this (and the duplicate), as I am confused about this. Please open a new ticket at https://github.com/php/php-src/issues if this is still a pressing issue. Previous Comments: ------------------------------------------------------------------------ [2018-08-14 21:06:51] cmb@php.net Oops, disregard my former comment, since it is nonsense. Anyhow, this is a duplicate of bug #66486. ------------------------------------------------------------------------ [2016-06-22 12:58:41] cmb@php.net Thanks for pointing out the space time format. It does look like to be intended to be a self-contained format, as several date formats *contain* whitespace (for instance, `Textual month and day`). And actually, that is quite contrary to what the reported wrote. > Anyway, interpreting whitespace as a current date looks > confusing, so this behavior probably deserves changing. I don't argue that accepting whitespace only as date time format is rather doubtful, but as often is the case with *changes*, this change would break BC. This is particularly bad, because the whitespace has been documented to be allowed. So, in a strict sense, this is not a bug. I'm changing to feature request. ------------------------------------------------------------------------ [2016-06-21 22:10:35] mtanalin at yandex dot ru To cmb@php.net: It looks like just common sense that whitespace is not a valid date or time — because it’s not a date, it’s…, well, whitespace. ;-) The “Date Formats” page [1] does not mention whitespace at all, the “Time Formats” page [2] lists space ([ \t]) as a possible value, but I’m not sure it is not about just a non-self-contained _token_ intended to be a part of a full valid date/time string containing _not_ just whitespace. Anyway, interpreting whitespace as a current date looks confusing, so this behavior probably deserves changing. [1] http://php.net/manual/en/datetime.formats.date.php [2] http://php.net/manual/en/datetime.formats.time.php ------------------------------------------------------------------------ [2016-06-17 09:35:06] cmb@php.net > Obviously, invalid should be whitespace-ONLY arguments (in other > words, becoming empty string after trim()), not arguments > _containing_ whitespace. Indeed, thanks. However, where is this documented? ------------------------------------------------------------------------ [2016-06-16 22:46:24] mtanalin at yandex dot ru To cmb@php.net: Obviously, invalid should be whitespace-ONLY arguments (in other words, becoming empty string after trim()), not arguments _containing_ whitespace. '2016-06-16 11:23' does not become an empty (zero-length) string after trimming whitespace. ------------------------------------------------------------------------ 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 https://bugs.php.net/bug.php?id=72425 -- Edit this bug report at https://bugs.php.net/bug.php?id=72425&edit=1

« previous php.bugs (#241499) next »