I’m running Umbraco in an Azure AppService with the timezone set to AWST. When saving a document, the Created datetime seems to be saved as localtime (AWST) instead of UTC, so when I view the document, the Created datetime is showing as AWST+8h. Is there some configuration I can apply to fix this? Thank you.
I have noticed this as well. There is this old bug report on GitHub which addresses the issue, but it seems to have been closed because there was no activity on it:
As far as I know, this same issue is still relevant on Umbraco 13, but I haven’t tested it in Umbraco 15.
Although I don’t think we can do much about the way this date is displayed in the backoffice, if you need to use these dates in your code, you may apply a timezone correction this way:
public static DateTime MakeUmbracoDateUtc(this DateTime umbracoDate, TimeZoneInfo sourceTimeZone)
{
var localDateTime = new DateTime(umbracoDate.Ticks, DateTimeKind.Unspecified);
return TimeZoneInfo.ConvertTimeToUtc(localDateTime, sourceTimeZone);
}
For your source timezone you’ll want to get the AWST timezone so that you get a proper UTC date.
This is not specific to Umbraco, but I strongly recommend using UTC for production environments. Time Zones are hard and can be the source of a lot of bugs (like this one) so removing them from the equation wherever possible is a good idea.
My site is targeted for users in a specific timezone, so it’s convenient being able to use local time in certain places in the backend, but I thought Umbraco would be saving dates to the DB in UTC which doesn’t seem to be the case as system time (in AWST) is being used instead. This is the last resort if there are no other solutions. Thank you.