Skip to content

[Question] Why is there no microseconds in date_create_from_format ? #15809

@zeriyoshi

Description

@zeriyoshi

Description

Hello,

It appears that date_create_from_format uses the current time for date and time components, but deliberately excludes microseconds.

$ php -r 'echo date_create_from_format("md", "0909")->format("Y-m-d H:i:s.u"), \PHP_EOL;'
2024-09-09 10:05:01.000000

Looking at the source code, it seems that there's a condition that specifically avoids handling microseconds. Does anyone know the reason for this? (Is it to prevent unintentionally creating instances that are not equal?)

If there isn't a strong reason for this behavior, I think it might be worth considering including microseconds in PHP 8.5. (Would this require an RFC?)

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