-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Modify with time on instance with timezone doesn't respect timezone #1080
Comments
Look at #883 |
I don't know why Carbon team decided to change Like you already wrote, what happens here is:
That is why you receive back You could use |
@Glavic Thanks for your comment. This is exactly what we did, but I consider it a workaround. And I consider Carbon's behavior a bug (although I didn't take the time to research the reason for it – there seems to be a good reason). First of all, it means that we have to set two separate configuration values per country for a single purpose. Second: The whole reason for applying this configuration to a non-utc-date was to enable us to trigger events independent of DST. Afterwards, the final date is persisted for scheduling as a UTC date anyways. |
Working on solution in #1070 PR. TY |
Calling modify with a time part doesn't respect the timezone of the instance it is applied to.
I added a unit test to prove that in my fork: https://github.com/tpraxl/Carbon/tree/prove-timezone-not-respected-bug:
This fails with:
This is most likely caused by the implementation of
\Carbon\Carbon::modify
, which sets the timezone to UTC before applying modify:I understand that this works for new instances – and is somehow required to work in that context – but it doesn't seem to work when applied to existing instances.
I also understand that this works when the timezone is considered local (see the other added unit test,
testModifyWithTimeRespectsTimezoneWhenLocal
, which passes).But when dealing with multiple timezones in your application, this should not be the way to go.
Simplified Usecase:
An application that configures relative scheduling dates in different timezones.
The text was updated successfully, but these errors were encountered: