Why does DateTime::createFromFormat() fails and returns a boolean in my second example?

后端 未结 3 1683
醉话见心
醉话见心 2021-02-18 14:13

When I run this the first one is correctly created into a date. The second one fails, returning a boolean and so I cannot format. Is the time out of range?

3条回答
  •  半阙折子戏
    2021-02-18 14:54

    Change the h to a big H, since the small one is 12-hours format and the big one is 24-hours format.

    You can see all formats in the manual. And a quote from there:

    h 12-hour format of an hour with leading zeros 01 through 12
    H 24-hour format of an hour with leading zeros 00 through 23

    Means right now your code fails, because there is no 15 in the 12 hour format.

提交回复
热议问题