When upgrading our site we ran the Power Shell Script to convert datetime columns in the database to UTC-format.
We chose the following option:
Scenario 1: Development machine is in the same time zone as the sitePM> Convert-EPiDatabaseToUtc
(I ran the above cmdlet on my local machine but my local server should be in the same time zone as the live server...)
When saving a date and time to a page type, for example
testPage.MyDateTime = new DateTime(2017, 1, 11, 15, 00, 00);
it appears as 2017-01-11 16:00 in EPiServer edit mode.
Is this the desired behavior?
I believe it is. The date and time gets saved as UTC, but edit mode automatically adjust it to your client settings, which is Swedish, I guess. It might be good to get a confirmation from Episerver employee though.
In earlier versions, in admin mode, UTC date/time was presented, ex. if you use scheduled jobs.
I would agree that it is the desired behavior.
Any editor that for instance is scheduling a publish would be expecting to set it after their local time.
UTC time is great for systems, less great for people :D
As of CMS 10 the code does ToUniversalTime on save and ToLocalTime on load, the UI diffs server time with client time and offsets accordingly. So the UI should say 15:00 in your example, I did a quick test and it seems to do as well. The behaviour of ToUniversalTime is described here: https://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.110).aspx
CMS 9 does it slightly different. In your example DateTimeKind would be Unspecified which will be treated as UTC. You can use DateTimeKind.Local in your example to avoid that we decide what you mean with Unspecified :)
Thanks everyone for answering!
Per: We're currently running EPiServer CMS 9 so I guess that is the reason why it appears as 16:00 and not 15:00?
Also did a test saving the datetime with DateTimeKind.Local and then I got 15:00.
Guess "everthing" will be alright after I've upgraded to CMS 10 :-)
Is another setup in play for scheduled jobs? I have culture="sv-SE" uiCulture="sv" in Web.config but jobs that executed 14:49 have 2017-10-20 12:49:08 in the Admin UI list.