-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 with tz pattern should not update linked timezone #10583
Comments
PHP 8.1.15, 8.2.2 and later this fix change offset of modify function #9891 (comment) If unknow format new DateTime('2015-01-01 00:00:00' . '+1 s') is timezone offset 01:00 from php all. |
@hormus You are right that the invalid unit is still ignored. Just tried it without any unit Since 8.1.5 the following sets the time zone to $dt = new DateTime('2015-01-01 00:00:00+01:00');
var_dump($dt->format('c'));
var_dump($dt->modify('+12:34')->format('c')); No sure if this is intended. |
hello @marc-mabe , if you read the previous fix for the modify function for php 8.1.15, 8.2.2 and later it is now possible to change timezone. |
Hi @hormus, The fix you linked is for setting the unix timestamp using Please don't understand me wrong. I don't want to say this is definitely a bug but it's for sure a behavior change that I don't see documented anywhere. |
If you open the link of the fix written in C++ code in that thread you can see the change from immutable to mutable "tmp_time" for timezone |
This doesn't look right indeed. |
Description
The following code: https://3v4l.org/EMU1K
Resulted in this output:
But I expected this output instead:
As you can see it's modifying the time zone offset from
+00:00
to+01:00
instead of doing nothing ass
is not a valid unit according to https://www.php.net/manual/en/datetime.formats.relative.php.It's interesting here because
s
is a common mistake as abbr. ofsecond
&sec
where alsoms
andµs
would be valid (which is another topic) but there is also no documented way of modifying the time zone usingmodify
and in this particular case it's effectively moving backward instead of forward.PHP Version
PHP 8.1.15 / PHP 8.2.2
Operating System
Linux
The text was updated successfully, but these errors were encountered: