Skip to content

DateTime::createFromFormat bug #16655

@gabriel-dina

Description

@gabriel-dina

Description

Run the following code on the 31 day of the current month (ex. october):

$dt = \DateTime::createFromFormat('Y-n','2024-11'); echo date("t", $dt->getTimestamp());
Resulted in this output:
31

But I expected this output instead:
30

Workaround:
$dt = \DateTime::createFromFormat('Y-n-d','2024-11-01'); echo date("t", $dt->getTimestamp());

PHP Version

PHP 8

Operating System

Ubuntu 20

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