Repository navigation
Read UNIX timestamps in the application timezone - #257
Merged
LukeTowers merged 1 commit intoOct 22, 2026
Merged
Conversation
Carbon 3 creates a date from a timestamp in UTC unless a timezone is given, so with a non-UTC app.timezone a numeric value assigned to a date attribute was stored as UTC wall-clock time and shifted by the offset. Laravel 12 passes date_default_timezone_get() for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
5 of 17 tasks
LukeTowers
approved these changes
Oct 22, 2026
LukeTowers
added a commit
to wintercms/winter
that referenced
this pull request
Oct 22, 2026
Carbon 2 read a bare Carbon::createFromTimestamp() in PHP's default timezone, which Laravel sets from app.timezone; Carbon 3 reads it as UTC. On wip/1.3 that converts every numeric UNIX timestamp an offset out for any project whose app.timezone is not UTC. Pass date_default_timezone_get() at each call site, as Laravel did in laravel/framework@8c61f50 (laravel/framework#50751). Companion to wintercms/storm#257, which fixed Model::asDateTime() the same way. System\Helpers\DateTime::makeCarbon() — Backend::dateTime() writes the result into <time datetime="…"> and winter.datetime.js reads it back with moment.tz(datetime, appTimezone), so a UTC wall time was reinterpreted as app-local and every backend list date column displayed an offset out. timeTense() and the CMS editor's last-modified tooltip format it directly, with the same result. System\Classes\MediaLibraryItem::lastModifiedAsString() — a file touched after local midnight was listed under the previous day. Backend\FormWidgets\DatePicker — integer minDate/maxDate bounds landed an offset away from their string equivalents. Backend::makeCarbon() needed no change: it calls setTimezone() afterwards, which preserves the instant. Eight tests across four classes, every one failing without the change, sharing a fixture instant of 23:30 UTC — the next day at 00:30 in Europe/Brussels, so a timezone slip moves the date as well as the clock. Full suite on wip/1.3: 882 tests green.
bennothommo
pushed a commit
to wintercms/wn-system-module
that referenced
this pull request
Oct 22, 2026
Carbon 2 read a bare Carbon::createFromTimestamp() in PHP's default timezone, which Laravel sets from app.timezone; Carbon 3 reads it as UTC. On wip/1.3 that converts every numeric UNIX timestamp an offset out for any project whose app.timezone is not UTC. Pass date_default_timezone_get() at each call site, as Laravel did in laravel/framework@8c61f50 (laravel/framework#50751). Companion to wintercms/storm#257, which fixed Model::asDateTime() the same way. System\Helpers\DateTime::makeCarbon() — Backend::dateTime() writes the result into <time datetime="…"> and winter.datetime.js reads it back with moment.tz(datetime, appTimezone), so a UTC wall time was reinterpreted as app-local and every backend list date column displayed an offset out. timeTense() and the CMS editor's last-modified tooltip format it directly, with the same result. System\Classes\MediaLibraryItem::lastModifiedAsString() — a file touched after local midnight was listed under the previous day. Backend\FormWidgets\DatePicker — integer minDate/maxDate bounds landed an offset away from their string equivalents. Backend::makeCarbon() needed no change: it calls setTimezone() afterwards, which preserves the instant. Eight tests across four classes, every one failing without the change, sharing a fixture instant of 23:30 UTC — the next day at 00:30 in Europe/Brussels, so a timezone slip moves the date as well as the clock. Full suite on wip/1.3: 882 tests green.
bennothommo
pushed a commit
to wintercms/wn-backend-module
that referenced
this pull request
Oct 22, 2026
Carbon 2 read a bare Carbon::createFromTimestamp() in PHP's default timezone, which Laravel sets from app.timezone; Carbon 3 reads it as UTC. On wip/1.3 that converts every numeric UNIX timestamp an offset out for any project whose app.timezone is not UTC. Pass date_default_timezone_get() at each call site, as Laravel did in laravel/framework@8c61f50 (laravel/framework#50751). Companion to wintercms/storm#257, which fixed Model::asDateTime() the same way. System\Helpers\DateTime::makeCarbon() — Backend::dateTime() writes the result into <time datetime="…"> and winter.datetime.js reads it back with moment.tz(datetime, appTimezone), so a UTC wall time was reinterpreted as app-local and every backend list date column displayed an offset out. timeTense() and the CMS editor's last-modified tooltip format it directly, with the same result. System\Classes\MediaLibraryItem::lastModifiedAsString() — a file touched after local midnight was listed under the previous day. Backend\FormWidgets\DatePicker — integer minDate/maxDate bounds landed an offset away from their string equivalents. Backend::makeCarbon() needed no change: it calls setTimezone() afterwards, which preserves the instant. Eight tests across four classes, every one failing without the change, sharing a fixture instant of 23:30 UTC — the next day at 00:30 in Europe/Brussels, so a timezone slip moves the date as well as the clock. Full suite on wip/1.3: 882 tests green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With a non-UTC
app.timezone, a UNIX timestamp assigned to a date attribute is stored shifted by the UTC offset onwip/1.3:Model::asDateTime()callsArgon::createFromTimestamp($value)without a timezone. Carbon 2 used PHP's default timezone for that, which Storm sets fromapp.timezone. Carbon 3 uses UTC instead. Laravel hit the same regression and fixed it the same way in laravel/framework@8c61f50 (#50751), which is still howHasAttributes::asDateTime()reads on 12.x. Projects on the default UTC timezone are not affected.date_default_timezone_get(), like Laravel.Europe/Brusselsas the default timezone and checks that the stored value and the timestamp read back are correct. It fails without the change.asDateTime()is the only numeric-timestamp cast in Storm. Laravel's commit also covered its othercreateFromTimestamp()call sites; the equivalent ones in Winter core are fixed in wintercms/winter#1579.🤖 Generated with Claude Code