Skip to content

DateInterval::createFromDateString does not throw non-relative items are present #8458

Closed

Description

@derickr

Description

The following code:

<?php
$d = DateInterval::createFromDateString('next weekday 15:30');
?>

Resulted in no warning.

But I expected a warning telling me that the 15:30 was going to be ignored.

PHP Version

PHP 8.2.0-dev

Operating System

No response

Activity

  1. self-assigned this
    on Apr 29, 2022
  2. changed the title [-]DateInterval::createFromDateString does not warn when non-relative items are present[/-] [+]DateInterval::createFromDateString does not throw non-relative items are present[/+] on May 5, 2022
  3. derickr commented on May 11, 2022

    @derickr
    MemberAuthor

    Merged.

  4. othercorey commented on May 12, 2022

    @othercorey
    Contributor

    @derickr The documentation for createFromDateString() says it takes the "relative formats" supported by the parser. That links to the relative formats page which includes this example:

    "2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months ago 5 days", "2 days ago"

    Should the 14:00 part be removed from those docs?

    https://www.php.net/manual/en/datetime.formats.relative.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions