It's usual for any dates shown in the UI to be converted in to the local users time based on their locale settings so if you're seeing this in the CMS backend that's quite normal.
Dates in the database should be saved as UTC then the UI takes care of localization for users.
> It's usual for any dates shown in the UI
I can't argue with that, but I am getting the page on backend part to do calculations and I guess it is more convinient to work with universal time
Convertion to local time should be on FE part, just as you said.
One thing missing in your code is the actual Saving / Publishing code that should be after clone.SpecialDateTimes = newDays;
Just in case you're seeing weird behavior as you've not actually saved it you should add that in, where below _repository is IContentRepository
List<DateTime> newDays = GetDays(); // all UTC dates, HomePage page = _contentLoader.Get<HomePage>(pageRefHere); var clone = page.CreateWritableClone() as HomePage; clone.SpecialDateTimes = newDays; // SpecialDateTimes is still in utc here _contentRepository.Save(clone, SaveAction.Publish, AccessLevel.NoAccess); page = _contentLoader.Get<HomePage>(pageRefHere); // re-read page var days = page.SpecialDateTimes; // all dates are local now
updated code example
I am trying to update page property programmatically.
The type of the property is IList<DateTime>.
The source list of dates contains only UTC dates (DateTimeKind.Utc)
After saving changes and re-reading page object it turns out that all dates are converted to Local time
The question is: what a heck?
Code demo is below.