Skip to content

Why PHP does not have a Date class? #15679

@ghost

Description

Description

Some of my properties represent a Date (2024-08-31), not a Date and Time (2024-08-31 15:10:00). Right now I have to use DateTimeImmutable type hint what gives wrong information about what a property represents.

I wonder why PHP still doesn't have Date class in 2024. Isn't is as simple as removing time information and time related methods from DateTime class? Date and DateTime instances would be comparable (==, >, < etc.) and during the comparison the time for Date instance would be implicitly 00:00:00.

P.S. Ofc Date class should be immutable so PHP doesn't end up with Date and DateImmutable 😄

Best

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