- BLOB storage and providers
- Client resources
- Configuring episerver
- Configuring episerver.dataStore
- Configuring episerver.framework
- Configuring episerver.packaging
- Configuring episerver.search
- Configuring episerver.shell
- Configuring module.config
- Configuring staticFile
- Configuring episerver.basicAuthentication
- Configuring .NET SignalR
- Configuring Image Service
- Configuring link validation
- Reading application settings programmatically
- Page types and templates
- Block types and templates
- IContentRepository and DataFactory
- Persisting IContent instances
- ContentType attribute
- Grouping content types and properties
- EditHint in MVC
- Creating a page programmatically
- Selecting content
- Converting page types for pages
- Refactoring content type classes
- Multilingual content
- Assets and media
- Planning deployments
- Installing database schema
- Setting up multiple sites
- Content Delivery Network (CDN) Configuration
- Configuring your email server
- Automatic schema updates
- Storing UTC date and time in the database
- Database mode
- Deployment scenarios
- Dynamic content
- Dynamic data store
- Event management
- Scheduled jobs
- Search integration
- Searching and filtering
- Installing and deploying Search Service
- About Episerver full-text search client
- About Episerver full-text search service
- Configuring Episerver full-text search client
- Configuring Episerver full-text search service
- Searching for pages based on page type
- Adding search providers
- Authentication and authorization
- Virtual roles
- Configuring Active Directory membership provider
- Recommendations for ASP.NET security settings
- Securing edit and admin user interfaces
- Federated security
- Forms authentication
- OWIN authentication
- Configuring mixed-mode OWIN authentication
- Permissions to functions
- Protecting users from session hijacking
- Managing cookies on the website
- EPiServer AspNetIdentity
- Integrate Azure AD using OpenID Connect
- User interface
- Context-sensitive components
- Service locator
- Describing content in the UI
- Shell profile
- Store architecture
- Message service pool
- Publish and subscribe messaging system
- Introduction to Dojo
- Using jQuery
- Plugging in a gadget
- Creating a component
- Extending the navigation
- WebSocket support
- Dashboard gadgets
- Command Pattern
- Object editing
- User notifications
- Virtual path providers
This content is archived. See latest version here.
Last updated: Oct 12 2015
Storing UTC date and time in the database
[New in CMS.Core 9.1]
By default, Episerver CMS uses the web server's local date and time for storing date and time in the database. It is possible to store Coordinated Universal Time (UTC) in the database instead by following the steps below. Storing date and time as UTC makes it possible to change web server's time zone or move the database between time zones. This change will be required in the next major version.
After switching to UTC in the database, all API calls that return local time before the switch continue to return local time. The main difference is that they are converted to and from UTC before being stored in and read from the database.
There are two ways to migrate to UTC in the database: using Visual Studio or running the stand-alone Power Shell Script. In both cases, the same code is executed, but the cmdlet in the Package Manager Console is a convenient way to start the migration from Visual Studio.
The migration script converts all datetime columns in the database. This process should take about a minute for a small site on a fast database server, and up to 30-60 minutes on a large site on a slower database server. It is possible to run the script on a running site as long as you restart the site after the migration is complete. During migration, any dates saved will be incorrect. The migration script places locks on tables during migration, so performance of a site that uses a lot of SQL queries will be negatively affected, and the process might slow down both the migration and the site.
Make sure the database is backed up before running the script. If the migration script fails, it can be restarted and will continue the batch where it was stopped but cannot roll back the complete operation. No changes to site configuration are required. The script stores the type of data and time used in the database.
Any custom Dynamic Data Stores (DDS) are not automatically converted, see date and time handling in DDS.
Option 1: Converting with Visual Studio
This option requires that the site is opened in Visual Studio and uses the connection string "EPiServerDB" in web.config. To get help about the cmdlet, run get-help Convert-EPiDatabaseToUtc –full. Open the project and the Package Manager Console to run the cmdlet as in the examples below.
Scenario 1: Development machine is in the same time zone as the site
Scenario 2: Development machine is not in the same time zone as the site
PM> Convert-EPiDatabaseToUtc -timeZone:([TimeZoneInfo]::FindSystemTimeZoneById("US Eastern Standard Time"))
Note: Change the time zone to a Windows time zone used in the environment where the content is stored.
Scenario 3: Azure Web Apps + SQL Azure
PM> Convert-EPiDatabaseToUtc –onlySwitchToUtc:$true
Note: Azure Web Apps and SQL Azure already run as UTC by default. But if you have used the WEBSITE_TIME_ZONE app setting in Azure Web Apps, you need to convert as Scenario 2, since the default UTC time is not used.
Scenario 4: Switching to UTC without converting
PM> Convert-EPiDatabaseToUtc –onlySwitchToUtc:$true
Note: If the exact date and time of historic data are unimportant, it is possible to flip the switch and let the CMS treat all existing and future dates and times as UTC.
Option 2: Converting in production without Visual Studio
The ConvertDatabaseToUtc.psm1 Power Shell script file is shipped in the NuGet package EPiServer.Framework but does not require Visual Studio to run. In development, you can find the file in the solution root (for example, packages/EPiServer.Framework.9.0.0/tools/ConvertDatabaseToUtc.psm1). The ConvertEPiDatabaseToUtc function can be run with the appropriate connection string and local time zone.
Start Windows Power Shell console and run:
PM> Import-Module <path to ConvertDatabaseToUtc.psm1>
PM> ConvertEPiDatabaseToUtc –connectionString "The connection string"
The options for this function are identical for the cmdlet, so the same scenarios apply. When running inside Visual Studio, it is a cmdlet (Convert-EPiDatabaseToUtc), but outside VS, it is a function (ConvertEPiDatabaseToUtc).