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

Update eloquent-mutators.md #9865

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

faiare
Copy link
Contributor

@faiare faiare commented Aug 27, 2024

This PR clarifies the behavior of timestamp columns in relation to date/datetime casting and timezone handling in Laravel.

Key points:

  1. This update is related to [10.x] Explain UTC behaviour when serialising dates #9287 and Serializing datetimes with custom format won't use the Carbon instance inner timezone. framework#49899.

  2. While the referenced issues state that dates are always displayed in UTC regardless of custom formatting, this is not entirely accurate. For non-timestamp columns, Carbon instances are created based on the app.timezone configuration and formatted in local time, as per the original documentation.

  3. However, for timestamp columns (created_at, updated_at), the timezone setting is lost during pre-casting processing (serializeDate, Date::parse, format methods), resulting in consistent UTC formatting.

  4. This discrepancy can lead to confusion for developers who expect consistent behavior across all date columns with similar cast settings.

  5. It's important to note that following the documentation's recommendation to keep app.timezone set to the default UTC value would prevent these inconsistencies.

  6. Given the potential impact on many applications, we believe updating the documentation is preferable to modifying this core behavior.

faiare and others added 2 commits August 27, 2024 13:44
Clarify UTC formatting for timestamp columns in date/datetime casting
@taylorotwell taylorotwell merged commit 2049220 into laravel:11.x Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants