Skip to content

8.2.9 DateTime:createFromFormat stopped parsing datetime with containing extra space. #11854

Closed
@mn7z

Description

@mn7z

Description

Starting of 8.2.9 version \DateTime:createFromFormat() starts to fail to parse date format, due extra space.

The date string Wed Aug 2 08:37:50 2023 - with extra space between Aug and 2. If extra space is removed
then it works as usual.

PHP versions <8.2.9 correctly parses the format, I've tested with 8.2.7 version in addition to 8.2.8.

The following code:

<?php

$dateTime = \DateTime::createFromFormat("D M d H:i:s Y", "Wed Aug  2 08:37:50 2023");

var_dump($dateTime);

Resulted in this output:

bool(false)

But I expected this output instead:

object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2023-08-02 08:37:50.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(3) "UTC"
}

PHP Version

PHP 8.2.9

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions