Migrate system dates from local server time to UTC#19798
Merged
AndyButland merged 10 commits intov17/feature/utc-system-datesfrom Jul 30, 2025
Merged
Migrate system dates from local server time to UTC#19798AndyButland merged 10 commits intov17/feature/utc-system-datesfrom
AndyButland merged 10 commits intov17/feature/utc-system-datesfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements a migration to convert existing system dates from local server time to UTC as part of Umbraco's effort to make date handling more consistent. The migration automatically detects the server timezone and updates all relevant datetime columns across multiple tables in the database.
Key changes:
- Adds a new migration
MigrateSystemDatesToUtcthat converts dates in 27 database columns from local time to UTC - Introduces configuration options to disable the migration or override timezone detection
- Includes validation for configuration settings to ensure valid timezone names
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
MigrateSystemDatesToUtc.cs |
Core migration class that handles timezone detection and updates datetime columns across all relevant tables |
SystemDateMigrationSettings.cs |
Configuration model defining migration settings with timezone and enabled properties |
SystemDateMigrationSettingsValidator.cs |
Validator ensuring configured timezone names are valid system timezones |
UmbracoPlan.cs |
Registers the new migration in the upgrade plan |
UmbracoBuilder.Configuration.cs |
Adds configuration registration for the new settings |
Constants-Configuration.cs |
Defines configuration key constant for the new settings |
SystemDateMigrationSettingsValidatorTests.cs |
Unit tests covering validation scenarios for the configuration settings |
Comments suppressed due to low confidence (2)
src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_0/MigrateSystemDatesToUtc.cs:102
- Missing opening brace for the method. The method declaration should be followed by an opening brace.
private static TimeSpan GetTimezoneOffset(string timeZoneName)
src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_0/MigrateSystemDatesToUtc.cs:107
- Parameter name 'columName' appears to be a typo. It should be 'columnName' for consistency and clarity.
private void MigrateDateColumn(IScope scope, string tableName, string columName, string timezoneName, TimeSpan timeZoneOffset)
src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_0/MigrateSystemDatesToUtc.cs
Outdated
Show resolved
Hide resolved
lauraneto
reviewed
Jul 29, 2025
src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_0/MigrateSystemDatesToUtc.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_0/MigrateSystemDatesToUtc.cs
Outdated
Show resolved
Hide resolved
1 task
lauraneto
approved these changes
Jul 30, 2025
…em-dates-data-migration # Conflicts: # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
5a21cf3
into
v17/feature/utc-system-dates
3 of 4 checks passed
AndyButland
added a commit
that referenced
this pull request
Aug 22, 2025
* Persist and expose Umbraco system dates as UTC (#19705) * Updated persistence DTOs defining default dates to use UTC. * Remove ForceToUtc = false from all persistence DTO attributes (default when not specified is true). * Removed use of SpecifyKind setting dates to local. * Removed unnecessary Utc suffixes on properties. * Persist current date time with UtcNow. * Removed further necessary Utc suffixes and fixed failing unit tests. * Added migration for SQL server to update database date default constraints. * Added comment justifying not providing a migration for SQLite default date constraints. * Ensure UTC for datetimes created from persistence DTOs. * Ensure UTC when creating dates for published content rendering in Razor and outputting in delivery API. * Fixed migration SQL syntax. * Introduced AuditItemFactory for creating entries for the backoffice document history, so we can control the UTC setting on the retrieved persisted dates. * Ensured UTC dates are retrieved for document versions. * Ensured UTC is returned for backoffice display of last edited and published for variant content. * Fixed SQLite syntax for default current datetime. * Apply suggestions from code review Co-authored-by: Laura Neto <[email protected]> * Further updates from code review. --------- Co-authored-by: Laura Neto <[email protected]> * Migrate system dates from local server time to UTC (#19798) * Add settings for the migration. * Add migration and implement for SQL server. * Implement for SQLite. * Fixes from testing with SQL Server. * Fixes from testing with SQLite. * Code tidy. * Cleaned up usings. * Removed audit log date from conversion. * Removed webhook log date from conversion. * Updated update date initialization on saving dictionary items. * Updated filter on log queries. * Use timezone ID instead of system name to work cross-culture. --------- Co-authored-by: Laura Neto <[email protected]>
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.
Prerequisites
Description
This is the second part of the effort to make Umbraco's handling of system dates more consistent by using UTC throughout.
#19705 makes changes such that we persist and expose UTC dates. This PR is a migration to update all the existing system dates stored in local server time to UTC.
The migration will run automatically and will detect the server time. If for some reason there's a need to disable the migration, or to override the detection of the local server time, this can be done in configuration:
To disable:
To use a specific timezone for the local server:
Testing
To test, run Umbraco and verify the migration completes via the log messages. Examine the database before and after to check the datetime values.
Verify the configuration values act as expected.
In my own testing I've run this locally where I'm on W. Europe Standard Time.
I've verified with SQL Server using the following queries:
Note that the first three go back one hour, and the last one two hours - this as the latter is during summer time when the offset from UTC is two hours rather than one. So with SQL Server we can handle daylight saving time in the conversions.
And with SQLite using:
Note here for all we just go back one hour. As per the comment in the code, we don't have the same features available in the database to handle daylight saving, but this is acceptable given it's likely non-production and these are historical dates where 100% accuracy is unlikely to be necessary.
And then with "Eastern Standard Time" configured as my local server time zone: