php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79304 Doc. for DateTime::createFromFormat/date_create_from_format not consistent
Submitted: 2020-02-24 19:57 UTC Modified: 2020-02-25 19:02 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: patrick dot kuijvenhoven at gmail dot com Assigned:
Status: Open Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-02-24 19:57 UTC] patrick dot kuijvenhoven at gmail dot com
Description:
------------
Reference https://www.php.net/manual/en/datetime.createfromformat.php

Please notice where X and Y are present in each column in the following table:

+---------------------+------------------------------+-----------------+
| format              | description                  | example         |
+---------------------+------------------------------+-----------------+
| X and Y             | ...  with (X) or without (Y) | 01 to 31 (X) or |
| (alphabetical sort) |  leading zeros ...           |  1 to 31 (Y)    |
+---------------------+------------------------------+-----------------+

This style works for "d and j", "D and l", "m and n".

The time variants "g and h" and "G and H" do not follow this style. 

This can be fixed by replacing "with or without" to "without or with" in the "description" column for these formats. So, suggested to rewrite as:

+--------------+-------------------------+--------------------------------+
| format       | description             | example                        |
+--------------+-------------------------+--------------------------------+
| g and h      | ... without or with ... | 01 thought 12 or 01 through 12 |
| G and H      | ... without or with ... | 0 thought 23 or 00 through 23  | 
+--------------+-------------------------+--------------------------------+

Another option could be to explicitly mention the format in the description, thus like "... without (G) or with (H) ...".



Patches

createfromformat.patch (last revision 2020-02-24 20:11 UTC by patrick dot kuijvenhoven at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-24 20:11 UTC] patrick dot kuijvenhoven at gmail dot com
The following patch has been added/updated:

Patch Name: createfromformat.patch
Revision:   1582575060
URL:        https://bugs.php.net/patch-display.php?bug=79304&patch=createfromformat.patch&revision=1582575060
 [2020-02-25 00:43 UTC] derick@php.net
This makes it read really weirdly, so I would say "Won't Fix" - if at all, change the examples around.
 [2020-02-25 19:00 UTC] patrick dot kuijvenhoven at gmail dot com
-Summary: Doc. for DateTime::createFromFormat/date_create_from_format not consistent +Summary: patrick.kuijvenhoven@gmail.com
 [2020-02-25 19:00 UTC] patrick dot kuijvenhoven at gmail dot com
I'm not a native English speaker, so I'm not a good judge concerning readability.

In case you prefer keeping the "with or without" and switching the examples around, then, for consistency the "g and h" and "G and H" should by switched as well (to "h and g" and "H and G" to be precise).

Let me know your thoughts. I'd be happy to supply a new patch.
 [2020-02-25 19:02 UTC] patrick dot kuijvenhoven at gmail dot com
-Summary: patrick.kuijvenhoven@gmail.com +Summary: Doc. for DateTime::createFromFormat/date_create_from_format not consistent
 [2020-02-25 19:02 UTC] patrick dot kuijvenhoven at gmail dot com
(Sorry, Summary altered by password manager by accident)
 [2022-12-01 05:40 UTC] Janet22coffect at gmail dot com
Glad you like it. We have been using this for several weeks now and it seems to be going nicely. (https://www.pfmlogin.net/)github.com
 [2022-12-19 10:02 UTC] Gordon896Herzog at gmail dot com
There's a bug report that exactly describes your problem :)

https://bugs.php.net/bug.php?id=51950

Since 2016-08-07, the bug report has been marked as "not a bug". You need to use strtotime or new DateTime instead.

The constants that have been defined apply to both formatting and parsing in the same way, which forces your ways.
(https://www.mckessonconnect.net/)github.com
 [2023-03-17 07:11 UTC] pfmlogin1 at gmail dot com
Hey there! I just wish to give you a huge thumbs up for your excellent info you have right here on this post. (https://www.pfmlogin.top/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 09:01:29 2024 UTC