Req #69661 [ReO->Wfx]: date_parse says the day is 1 instead of false

From: Date: Fri, 13 May 2022 14:49:58 +0000
Subject: Req #69661 [ReO->Wfx]: date_parse says the day is 1 instead of false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241503@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69661&edit=1

 ID:                 69661
 Updated by:         derick@php.net
 Reported by:        php-bugs at xpaw dot me
 Summary:            date_parse says the day is 1 instead of false
-Status:             Re-Opened
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   Ubuntu
 PHP Version:        5.6.9
 Block user comment: N
 Private report:     N

 New Comment:

If you want more control over parsing dates, where the behaviour of strtotime/ the DateTime
constructor does not apply, you can use the date_parse_from_format function, like:

php -r 'var_dump(date_parse_from_format("M Y", "May 2013"));'

This will then show you the right information:

array(12) {
  'year' =>
  int(2013)
  'month' =>
  int(5)
  'day' =>
  bool(false)


Previous Comments:
------------------------------------------------------------------------
[2018-02-14 22:08:35] cmb@php.net

Okay, changing to feature request.

------------------------------------------------------------------------
[2018-02-14 18:48:41] php-bugs at xpaw dot me

Documented behaviour does not make it correct behaviour.

Currently I have no way of testing if the day field is default or was actually parsed from the
input.

------------------------------------------------------------------------
[2018-02-14 18:27:38] cmb@php.net

Indeed, this is documented behavior!

------------------------------------------------------------------------
[2017-01-04 17:04:24] contact at frank-liepert dot de

This is expected behaviour, see "Textual month and four digit year (Day reset to 1)" on http://php.net/manual/de/datetime.formats.date.php

------------------------------------------------------------------------
[2015-05-19 11:54:25] cmb@php.net

See also <http://3v4l.org/eAiXb>.

------------------------------------------------------------------------


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=69661


--
Edit this bug report at https://bugs.php.net/bug.php?id=69661&edit=1


Thread (7 messages)

« previous php.bugs (#241503) next »