After upgrade to Episerver 10, all DateTime fields have had their time shifted. Why?

Vote:
 

I was under the impression that the Convert-EPiDatabaseToUtc cmdlet's job was to convert DateTime values so they were UTC, but would still work as expected when displayed in local time. Well, one of our customers have just reported to us that all their time values have been shifted forward by one hour after the upgrade (which makes sense, since we're UTC+1). How could this happen? The fields are declared like this:

[Display(Name = "Starttid", Order = 100)]
[Required]
public virtual DateTime StartTime { get; set; }

[Display(Name = "Sluttid", Order = 110)]
public virtual DateTime StopTime { get; set; }
#186831
Edited, Jan 05, 2018 9:14
Vote:
 

My understanding is:

From CMS 10, values are stored in the database are stored as UTC

The cmdlet converts all datetimes based on the server timezone where it is executed. I.e. if the server was set in Central European Time, the dates would be adjusted by an hour in the datebase or two hours if the date fell within a daylight saving adjustment (ie between April and October in the UK).

  • A date originally stored as 1/5/2017 00:00 would become 30/4/2017 22:00 in the database (as daylight saving is applied in April / May) so CET (DST) = UTC + 2 hours 
  • A date originally stored as 1/12/2017 00:00 would become 30/11/2017 23:00 in the database  CET = UTC + 1 hour 

What I've also noticed is that when viewing dates through the Episerver interface, they are adjusted to the local time (based on the user's local time passed via browser header), so you don't see the value stored in the database, you see the value stored in the database adjusted to your browsers local timezone (calculated at the exact date). This way all editors regardless of timezone will see the same moment.

This has confused me as some dates are an hour different than I expected, but this is because the conversion to local from UTC respects daylight savings, so there is an extra hour.

The Episerver API also converts dates to local time (based only on the server timezone) rather than the browser headers. You need to be aware of this when comparing datetimes especially with dates from external systems. When moving to DXC we had an issue where the data we migrated over (Episerver 10) was stored as UTC, but the old hosting environment was set up as GMT, where as the Azure DXC environment was UTC. This meant the conversions to Local time were different on the environment and the date comparison which previously worked were sometimes out by an hour (during Daylight savings).

#186839
Edited, Jan 05, 2018 13:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.