Skip to content

Wrong month by DateTime::format('F') #17625

@christian-m-travanto

Description

@christian-m-travanto

Wron output by DateTime Format

The following code:

$monthNum = 2;  // 1 January, 3 also March but that is right
$dateObj = DateTime::createFromFormat('n', $monthNum);
echo $dateObj->format('F');
<?php

Resulted in this output:

March

But I expected this output instead:

February

PHP Version

8.2 also older

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