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

DateTime modify function backward compatibility break on 8.2 #10357

Closed
pkusmierczyk opened this issue Jan 17, 2023 · 2 comments
Closed

DateTime modify function backward compatibility break on 8.2 #10357

pkusmierczyk opened this issue Jan 17, 2023 · 2 comments

Comments

@pkusmierczyk
Copy link

Description

The following code:

<?php
$modifiedDate = (new DateTime('2023-01-17'))->modify(sprintf('+%s days', $days))->format('Y-m-d');

Resulted in this output:
For values of $days lower than 0 results are incorrect (according to version 8.1). If value is -1 we get

'2023-01-18'

But I expected this output instead:

'2023-01-16'

PHP Version

8.2

Operating System

Ubuntu 20.04

@pospjan
Copy link

pospjan commented Jan 17, 2023

@pkusmierczyk I think that would be the same as here #9950, so it is documented BC (via php/doc-en@ef51b1c) "number symbols in relative formats no longer accept multiple signs, e.g. +-2"

@pkusmierczyk
Copy link
Author

Yes, its the same, I couldn't find anything similar before so I have created a new issue

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