Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
derickr opened this issue Apr 29, 2022 · 2 comments

Comments

@derickr
Copy link
Member

derickr commented Apr 29, 2022

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

@derickr derickr self-assigned this Apr 29, 2022
@derickr derickr changed the title DateInterval::createFromDateString does not warn when non-relative items are present DateInterval::createFromDateString does not throw non-relative items are present May 5, 2022
derickr added a commit to derickr/php-src that referenced this issue May 5, 2022
derickr added a commit to derickr/php-src that referenced this issue May 9, 2022
derickr added a commit that referenced this issue May 11, 2022
@derickr
Copy link
Member Author

derickr commented May 11, 2022

Merged.

@derickr derickr closed this as completed May 11, 2022
@othercorey
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants